這裏是我的代碼,我現在使用,但仍然得到各種錯誤:由於未捕獲異常而終止應用程序'NSInternalInconsistencyException?任何線索?
No visible @interface for 'HomeViewController' declares the selector 'getCount'
而且
/Volumes/Lex/HomeViewController.h:12:12: Required for direct or indirect protocol 'UIPickerViewDataSource'
/Volumes/Lexar/HomeViewController.m:15:17: Incomplete implementation
我的代碼(.m文件)
- (void)viewDidLoad
{
[super viewDidLoad];
PFUser *currentUser = [PFUser currentUser];
if (currentUser) {
NSLog(@"Current user: %@" , currentUser.username);
}
else {
[self performSegueWithIdentifier:@"showLogin" sender:self];
self.pickerView.dataSource = self;
self.pickerView.delegate = self;
}
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent: (NSInteger)component
{
if ([self getCount] == 0)
return 1;
return [self getCount];
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent: (NSInteger)component reusingView:(UIView *)view {
if ([self getCount] == 0)
return nil;
}
- (IBAction)logout:(id)sender {
[PFUser logOut];
[self performSegueWithIdentifier:@"showLogin" sender:self];
}
@end
和標題
/// .h controller
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface HomeViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate>
@property (strong, nonatomic) IBOutlet UIPickerView *pickerView;
- (IBAction)logout:(id)sender;
@end
發佈您的代碼。 –
請分享相關的代碼。 – Suryakant
我沒有任何代碼,就是這樣。我只是通過故事板將選取器放置在控制器中,然後當我測試運行應用程序時,當我點擊未填充的選取器時拋出該錯誤 –