2015年3月23日 星期一

解決Xcode外掛無法使用問題

解決xcode下外掛無法使用

到以下目錄

~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/

找到你要的外掛 打開套件內容

選擇info.plist檔,

於DVTPluginCompatibilityUIDs加入

XCodde 6.3.2
E969541F-E6F9-4D25-8158-72DC3545A6C6
並執行
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add `defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`

XCode 6.3
9F75337B-21B4-4ADC-B558-F9CADF7073A7
Xcode 6.2
A16FF353-8441-459E-A50C-B071F53F51B7

Xcode 6GM:
C4A681B0-4A26-480E-93EC-1218098B9AA0


2015年3月12日 星期四

iOS Container view與Parent UIViewController的溝通



若parent裡要呼叫container裡面的屬性




self.ChildViewController.yourProperty = yourValue




若container要呼叫parent的屬性:




((YourParentViewControllerClassType *)self.parentViewController).yourParentProperty = TheValueYouWant;

2015年3月2日 星期一

UIContainer View呼叫Parent ViewController屬性與傳值

UIContainer VIew 傳值給ParentViewController




主要是選擇使用delegate的方式,

在ParentViewController.h



#import 
#import "ChildViewController.h"

@interface ViewController : UIViewController<ChildViewControllerDelegate>

@property (weak, nonatomic) IBOutlet UITextField *parentTF;

@end


ParentUIViewController .m  檔

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([segue.identifier isEqualToString:@"mySegue"])
    {
        ChildViewController *cVC = segue.destinationViewController;
        cVC.delegate = self;
    }
}

-(void) done:(NSString *)someText andChildBtn:(UIButton *)childBtn
{
    self.parentTF.text = someText;
    [childBtn setTitle:@"changed" forState:UIControlStateNormal];
    [self.view setBackgroundColor:[UIColor darkGrayColor]];
}
@end


而在 ChildViewController.h 要宣告定義好protocol讓UIViewController能夠處理你要他做的事情



#import <UIKit/UIKit.h>
// 傳到到另個 ViewController ,所以自己要先定義protocol
@protocol ChildViewControllerDelegate <NSObject>

-(void)done:(NSString*)someText andChildBtn:(UIButton*)childBtn;

@end

@interface ChildViewController : UIViewController

@property(nonatomic,assign) id<ChildViewControllerDelegate> delegate;

@property (weak, nonatomic) IBOutlet UIButton *passValueBtn;
@property (weak, nonatomic) IBOutlet UITextField *childTF;
- (IBAction)passValueAction:(id)sender;
@end



然後.m檔去呼叫delegate方法

#import "ChildViewController.h"

@implementation ChildViewController

- (IBAction)passValueAction:(id)sender {
    
    [self.delegate done:self.childTF.text andChildBtn:self.passValueBtn];
}
@end


這樣就可以透過container view controller去傳值給parentviewcontroller

而還有夠簡易的方式是

直接由container view controller去修改parent view controller的值

例如


 ((ViewController*)self.parentViewController).lb.text =[NSString stringWithFormat:@"%ld",indexPath.row];

以上是由container view 呼叫 parent view的屬性