我正在使用 ARC 和故事板为 iOS5 开发一个项目。
我有一个带有注释的地图视图,其中有一个显示按钮转到我的 DetailView(这是一个 TableViewController),但是当它应该被加载时,我收到以下错误:
2012-07-18 14:09:43.328 Zone-It-new[1966:707] Loadded the view for MapViewController
2012-07-18 14:11:40.467 Zone-It-new[1966:707] -[UILabel copyWithZone:]: unrecognized selector sent to instance 0x138470
2012-07-18 14:11:40.470 Zone-It-new[1966:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILabel copyWithZone:]: unrecognized selector sent to instance 0x138470'
*** First throw call stack:
(0x3748488f 0x35189259 0x37487a9b 0x37486915 0x373e1650 0x311997ef 0x31195059 0x31194711 0x3119466b 0x311945e7 0x31284f63 0x311979bb 0x311973ad 0x31191b8b 0x311917d5 0x9386d 0x3120a93d 0x31284627 0x37cf5933 0x37458a33 0x37458699 0x3745726f 0x373da4a5 0x373da36d 0x33b99439 0x31186cd5 0x924b3 0x92458)
terminate called throwing an exception(lldb)
这是我的 detailviewcontroller.h:
#import <UIKit/UIKit.h>
#import "Event.h"
@interface DetailViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource>{
IBOutlet UILabel *title;
IBOutlet UILabel *description;
IBOutlet UILabel *zone;
IBOutlet UILabel *gemeente;
IBOutlet UILabel *plaats;
IBOutlet UILabel *deelnemers;
IBOutlet UILabel *start;
IBOutlet UILabel *einde;
IBOutlet UILabel *id_nr;
}
@property (nonatomic) Event *event;
@property (nonatomic) IBOutlet UILabel *title, *zone, *description, *gemeente, *deelnemers, *start, *einde, *plaats, *id_nr;
@end
DetailViewController.m 的一部分
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[[self navigationController] setNavigationBarHidden:NO animated:YES];
/*title.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;*/
[title lineBreakMode];
[title setText:[event title]];
[title sizeToFit];
gemeente.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
[title lineBreakMode];
[gemeente setText:[event gemeente]];
}
这是通过 ListView 创建视图的地方:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
SingletonManager *sharedManager = [SingletonManager sharedManager];
[detail setEvent:[sharedManager.eventsManager objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:detail animated:YES];
}
事件.h
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface Event : NSObject <MKAnnotation>
// required property from mkanotation
@property (nonatomic) CLLocationCoordinate2D coordinate;
// Optional
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *description;
@property (nonatomic, copy) NSString *zone;
@property (nonatomic, assign) NSString *gemeente;
@property (nonatomic, copy) NSString *straat;
@property (nonatomic, assign) int deelnemers;
@property (nonatomic, copy) NSDate *start;
@property (nonatomic, copy) NSDate *einde;
@property (nonatomic, copy) NSString *plaats;
@property (nonatomic, readonly) int id_nr;
@property (nonatomic, assign) int huisnummer;
@end
----- 更多调试信息-----
使用异常断点时,它在此处停止:
[self.navigationController pushViewController:detail animated:YES];
安慰:
2012-07-18 15:53:46.691 Zone-It-new[179:707] Loadded the view for MapViewController
2012-07-18 15:54:01.940 Zone-It-new[179:707] -[UILabel copyWithZone:]: unrecognized selector sent to instance 0x170bb0
(lldb)