-1
我是ios開發中的新成員,我正在使用2視圖控制器創建應用程序。我使用協議和委託從一個控制器發送數據到預覽控制器。數據通過罰款。我的問題是,在控制器中獲取數據的協議方法中的代碼是不執行的。該方法中的NSLOG是執行的,但其餘的gode no。 任何想法爲什麼發生這種情況?從控制器來自protocole的方法中的代碼未被執行
代碼誰發送的數據:
.H
@class GeoCoding_controller;
@protocol GeoContDelegate <NSObject>
-(void)addItemViewController:(GeoCoding_controller *)controller didFinishEnteringItem: (NSString *)item;
@end
.M
NSString *itemToPassBack = [NSString stringWithFormat:@"%@,%@,%@",final_loc[indexPath.row][@"form_address"],final_loc[indexPath.row][@"lat"],final_loc[indexPath.row][@"lng"]];;
First_view_controller *first_cont = [self .storyboard instantiateViewControllerWithIdentifier:@"first_view"];
[self presentViewController:first_cont animated:YES completion:nil];
[self.delegate addItemViewController:self didFinishEnteringItem:itemToPassBack];
守則控制器誰得到的數據:
.H
@interface First_view_controller : UIViewController<CLLocationManagerDelegate,GMSMapViewDelegate,GeoContDelegate>
.M
-(void)addItemViewController:(GeoCoding_controller *)controller didFinishEnteringItem:(NSString *)item{
double delay = 10.0;
dispatch_time_t poptime = dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC);
dispatch_after(poptime, dispatch_get_main_queue(), ^{
NSArray *foo = [item componentsSeparatedByString:@","];
NSString *address = [NSString stringWithFormat:@"%@ %@ %@",[foo objectAtIndex:0],[foo objectAtIndex:1],[foo objectAtIndex:2]];
double lat = [[foo objectAtIndex:3]doubleValue];
double lng =[[foo objectAtIndex:4] doubleValue];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:lat longitude:lng zoom:18];
MAP.camera = camera;
edtaddress.text = address;
NSLog(@"data from controller : %@", item);
});
}
請添加代碼對你的問題。 –
請只發布相關的代碼。不需要兩個類的整個.h和.m文件。 – rmaddy
對不起,先不添加代碼!!! – user3734693