我是iOs的初学者.我要在表视图控制器中查看列表.我的应用程序是故事板应用程序.我做了以下代码转到下一个视图.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
LawyerViewController *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"LawyerViewController"];
dvc.lawyer = @"Thisara";//[self.myObject objectAtIndex:indexPath.row];
[self.navigationController pushViewController:dvc animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
在我的LawyerViewController头文件中,我定义了以下属性.
@property (nonatomic, strong) NSString *lawyer;
Run Code Online (Sandbox Code Playgroud)
当我点击单元格时,我遇到了以下错误.
2014-07-26 23:56:14.420 lawyerapp[3626:60b] -[UIViewController setLawyer:]: unrecognized selector sent to instance 0x8cdd1f0
2014-07-26 23:56:14.424 lawyerapp[3626:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setLawyer:]:
unrecognized selector sent to instance 0x8cdd1f0'
Run Code Online (Sandbox Code Playgroud)
我该如何解决.
提前致谢!
我在实施谷歌+登录时遇到以下错误.
2015-02-11 21:23:27.925 SIR[3761:154305] -[__NSDictionaryM gtm_httpArgumentsString]: unrecognized selector sent to instance 0x78e53cb0
2015-02-11 21:23:27.929 SIR[3761:154305] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [__NSDictionaryM gtm_httpArgumentsString]: unrecognized selector sent to instance 0x78e53cb0'
- (void)viewDidLoad {
[super viewDidLoad];
checkUp=NO;
class=[[ArrayClass alloc]init];
class.delegate=self;
[class calledWhenStringISPArsed:@"1"];
datePicker.tintColor=[UIColor whiteColor];
[datePicker setValue:[UIColor whiteColor] forKeyPath:@"textColor"];
timeTextField.delegate=self;
textField1.delegate=self;
textField2.delegate=self;
testField3.delegate=self;
textField4.delegate=self;
textField5.delegate=self;
textField6.delegate=self;
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
//signIn.shouldFetchGoogleUserEmail = YES; // Uncomment to get the user's email
// You previously set kClientId …Run Code Online (Sandbox Code Playgroud) 当我尝试使用我在代码中创建的按钮时,不确定为什么我收到"无法识别的选择器发送到类"错误.
这是我的代码:
let sendButton: UIButton = {
let button = UIButton(type: .system)
button.setTitle("Send", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.backgroundColor = #colorLiteral(red: 0.5098039216, green: 0.5215686275, blue: 0.8392156863, alpha: 1)
button.layer.cornerRadius = 5
button.isUserInteractionEnabled = true
button.addTarget(self, action: #selector(postComment), for: .touchUpInside)
return button
}()
Run Code Online (Sandbox Code Playgroud) 我知道这种问题反复浮动一遍又一遍,但我找不到任何答案,我无法解决我的问题:(.
我正在开发一个应用程序,我需要获取音频流.我决定和MPMoviePlayer一起去,所以我这样做了:
#import "MediaPlayer/MediaPlayer.h"
@interface FirstViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
...
IBOutlet MPMoviePlayerViewController *theMovie;
...
}
...
@property (nonatomic, retain) MPMoviePlayerViewController *theMovie;
Run Code Online (Sandbox Code Playgroud)
在实现中,我只是@ synthesize -d它.
现在,每当我分配它并尝试访问它的成员或方法时,我得到这个该死的错误无法识别的选择器在初始化后的第一行发送到实例:
self.theMovie = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://netvarp.kringvarp.fo:554/radio/16/playlist.m3u8"]];
self.theMovie.moviePlayer.controlStyle = MPMovieControlStyleNone;
...
Run Code Online (Sandbox Code Playgroud)
(这是在viewDidLoad方法中).
我在这行中得到错误:
self.theMovie.moviePlayer.controlStyle = MPMovieControlStyleNone;
Run Code Online (Sandbox Code Playgroud)
或者我在初始化后调用的任何东西.
如果我删除IBOutlet,如果我在没有'self'的情况下调用它,如果声明一个MPMoviePlayerController,也是如此.我无法弄清楚我2天做错了什么!真难为情 :(
任何帮助将不胜感激.
我忘了提及,目标操作系统> 3.0.在模拟器上一切正常,但在设备上没有(iPhone 2G和iPhone 3G,都是IOS 3.1.3)
我得到" - [__ NSArrayI addObject:]:无法识别的选择器发送到实例0x10dd15ee0"这里,当我尝试将addObject添加到NSMutableArray时.我不知道为什么.
我有一组嵌套的自定义类.WTEvent有一个名为mats的NSMutableArray属性,它由WTMat对象组成.mats有一个名为bouts的WTBout对象的NSMutableArray.
我希望能够在比赛中更新一回合,同时单独留下剩下的比赛.在这里,我找到了我需要分配一个回合的垫子.如果没有初始化,我会初始化它.然后,如果它是空的,我尝试添加一个newBout,它崩溃了.
我不应该像这样更改NSMutableArray的元素吗?
// Locate the correct mat
WTMat* mat = [self getMatFromBoutKey:[updateData valueForKey:@"boutKey"]];
WTBout* newBout = [WTBout buildBoutFromDictionary:updateData];
// need to initialize bouts
if ([mat bouts] == nil) {
NSLog(@"Initializing bouts");
NSMutableArray* newBouts = [[NSMutableArray alloc] init ];
[mat setBouts:newBouts];
}
if ([[mat bouts] count]) {
// if bouts has bouts, then adjust the bout stack
NSLog(@"bouts is not empty");
} else {
// if bouts is empty, just add a bout
NSLog(@"Adding a …Run Code Online (Sandbox Code Playgroud) 当我在代码中创建了一个UITableView时,将它作为子视图添加到代码中,它一切正常.可以看到绿色的桌面视图.我为此创建的代码示例.
- (void)getOverviewTable
{
// Adding the TableView
OverviewTableViewController *overviewTableViewController = [[OverviewTableViewController alloc] init];
UITableView *overviewTableView = [[UITableView alloc] initWithFrame:(CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height))];
// Set the datasource and delegete will come here
[overviewTableView setBackgroundColor:[UIColor greenColor]];
[self.view addSubview:overviewTableView];
}
Run Code Online (Sandbox Code Playgroud)
但是在我为TableView设置了DataSource和Delegete后,我会收到警告.达到它的总代码如下:
- (void)getOverviewTable
{
// Adding the TableView
OverviewTableViewController *overviewTableViewController = [[OverviewTableViewController alloc] init];
UITableView *overviewTableView = [[UITableView alloc] initWithFrame:(CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height))];
// Set the datasource and delegete will come here
[overviewTableView setDataSource:overviewTableViewController];
[overviewTableView setDelegate:overviewTableViewController];
[overviewTableView setBackgroundColor:[UIColor greenColor]];
[self.view addSubview:overviewTableView];
} …Run Code Online (Sandbox Code Playgroud) 我在视图控制器中有一个UITableView设置,用于填充函数返回的JSON数据.当我加载MatchCenterViewController时,应用程序崩溃,我收到以下错误:
2014-06-07 15:56:23.651 Parse+Storyboard[6848:607] -[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0xaa29730
2014-06-07 15:56:23.825 Parse+Storyboard[6848:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0xaa29730'
*** First throw call stack:
(
0 CoreFoundation 0x02a8c1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0264a8e5 objc_exception_throw + 44
2 CoreFoundation 0x02b29243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x02a7c50b ___forwarding___ + 1019
4 CoreFoundation 0x02a7c0ee _CF_forwarding_prep_0 + 14
5 UIKit 0x0156f94c -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2510
6 UIKit 0x0157323d -[UITableViewRowData …Run Code Online (Sandbox Code Playgroud) http://pt-br.tinypic.com/view.php?pic=300rxip&s=8#.VDhDStTF8mc
正如您在上面看到的那样,我的UIImageView连接到TableViewCell(我的声誉太低,无法发布图像,因此我必须将其上传到tinypic).
此图片的单元格代码位于:
#import <UIKit/UIKit.h>
@interface ExtratoDeNotasSideMenuTableViewCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UIImageView *image;
@property (strong, nonatomic) IBOutlet UILabel *label;
@end
Run Code Online (Sandbox Code Playgroud)
之后我指定它接收的图像:
- (ExtratoDeNotasSideMenuTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ExtratoDeNotasSideMenuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ExtratoDeNotasSideMenuTableViewCell" forIndexPath:indexPath];
// Configure the cell...
cell.image.image = [UIImage imageNamed:@"Icone_SideBar.png"];
cell.label.text = [NSString stringWithFormat:@"%@", [self.menuItens objectAtIndex:indexPath.row]];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用,消息:"***终止应用程序由于未捕获的异常'NSInvalidArgumentException',原因:' - [UIImageView _isResizable]:无法识别的选择器发送到实例0x7fa81356da40'"继续显示.任何帮助将不胜感激.
我正在努力教自己客观-c.我曾经(~10年前)用c ++很好,所以我认为这不应该太难,但是经过这么多年的python和各种数学编程语言,我在指针上很生锈,我认为是可能是造成这种情况的原因.
无论如何,我一直在为文档中明确存在的方法和xcode的调试输出(我不是很熟悉,也许这是错误的)的方法得到无法识别的选择器错误,这表明这些对象已初始化.我试图尽可能小地制作以下示例.这是我写的课程:
// Graph.h
#import <Foundation/Foundation.h>
@interface Graph : NSObject
@property NSMutableSet *myObjects;
- (id)initWithNumElements:(int)total;
- (NSMutableSet *)addOneMore:(NSMutableSet *)vertices;
- (NSMutableSet *)addTo:(NSMutableSet *)R from:(NSMutableSet *)P;
@end
Run Code Online (Sandbox Code Playgroud)
它的实施:
// Graph.m
#import "Graph.h"
@implementation Graph
// Put numbers 0, ..., total - 1 into the objects of self
- (id)initWithNumElements:(int)total {
self = [super init];
if (self) {
NSMutableSet *objects = [[NSMutableSet alloc] init];
for (int i=0; i<total; i++) {
[objects addObject:[NSNumber numberWithInt:i]];
}
_myObjects = objects;
}
return self;
} …Run Code Online (Sandbox Code Playgroud) 我在静态表视图中添加了一些textField和textView.代码很好,并运行在xcode 6.4/ios 8.*但它抛出异常,我无法跟踪.现在我在xcode 7.2上调试代码(swift2.2)
我尝试过设置符号和特殊的断点,但没有运气:(
以下是崩溃的堆栈跟踪,提前感谢您的宝贵帮助.
2015-12-14 16:07:07.989 TuteMate[3380:90711] -[NSNull length]: unrecognized selector sent to instance 0x10ccc6af0
Run Code Online (Sandbox Code Playgroud)
从特殊的断点:
CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:]:
-> 0x10504e3c0 <+0>: pushq %rbp
0x10504e3c1 <+1>: movq %rsp, %rbp
0x10504e3c4 <+4>: pushq %r15
0x10504e3c6 <+6>: pushq %r14
0x10504e3c8 <+8>: pushq %rbx
0x10504e3c9 <+9>: pushq %rax
0x10504e3ca <+10>: movq %rdx, %r14
0x10504e3cd <+13>: movq %rdi, %rbx
0x10504e3d0 <+16>: movq 0x216c79(%rip), %rsi ; "class"
0x10504e3d7 <+23>: callq *0x229e1b(%rip) ; …Run Code Online (Sandbox Code Playgroud) ios ×6
objective-c ×6
swift ×2
uitableview ×2
xcode ×2
google-plus ×1
instance ×1
iphone ×1
login ×1
properties ×1
storyboard ×1
tableview ×1
uiimageview ×1