新手求助:学习UIPickerView遇到Thread 1:EXC

鉴于吧里新手求助贴实在太多
故整合资源造福山吧众基_山地车吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0可签7级以上的吧50个
本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:327,228贴子:
鉴于吧里新手求助贴实在太多
故整合资源造福山吧众基
调整变速后拨前拨变速线安装后拨保养蹭碟调整油碟线碟碟片沾油飞轮拆卸1 2 油碟维护灌油喜马诺的avid的保养心得换油排空气花鼓禧玛诺久裕当然还有吧友最喜欢的改无视窗更换内外胎以上内容均为lz转载
只不过很多人不知道在哪找 所以楼主总结一下 为吧友造福
教程都很详细哦
应吧友的提议,我决定重...
  经一些吧友提议将资...
小米手机线刷教程 http:...
录取分数线:http://tie...
@詈奁 楼主只提供文章资...
本帖收集贴吧测试能玩...
1L祭天@MY_冥忧 @起个ID...
刚才忘记镇楼图了在艾特...
明天要去一个未知的地方...
之前处于A的状态,体服...
@仍然被占有
在线等 谢谢
并没有什么卵用,新手还是会像大爷一样
说的根本吧精品里面没有一样
一款真正“球迷做给球迷”的足球类游戏!
然而新手直接无视此类帖子……
精品吧里面有
3D篮球现场
但是我依然收藏了
整合也轮不到你
内&&容:使用签名档&&
保存至快速回贴UIPickerView多滚轮应用
今天还是写demo不过没有写完,写了一些基础的,可以给不会用pickerView的新朋友参照下
static float currentFontSize = 10.0f;
static NSString
*currentFontName = @"Arial";
static NSString
*currentFontColor = nil;
@implementation
FileDemoViewController
@synthesize textInfoP
@synthesize setTextB
@synthesize textL
@synthesize fontN
@synthesize fontS
@synthesize fontC
@synthesize textInfoD
#pragma mark -
#pragma mark save action
-(IBAction)storeAndSet
NSFileManager *fileManager =
[NSFileManager defaultManager];
NSArray *path =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDictionary =
[path objectAtIndex:0];
NSString *filePath =
[documentDictionary stringByAppendingPathComponent:@"test"];
[fileManager
createFileAtPath:filePath
contents:nil attributes:nil];
//[self.textInfoDic writeToFile:filePath atomically:YES
atomically:YES];
[self.textInfoDic release];
#pragma mark -
#pragma mark UIPickerViewDelegate methods
(CGFloat)pickerView:(UIPickerView *)pickerView
rowHeightForComponent:(NSInteger)component
return 60.0f;
(CGFloat)pickerView:(UIPickerView *)pickerView
widthForComponent:(NSInteger)component
return 80.0f;
*)pickerView:(UIPickerView
*)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
NSString *pTitle = nil;
if (component == 0) {
pTitle = [self.fontNames objectAtIndex:row];
if (component == 1) {
pTitle = [self.fontSize objectAtIndex:row];
if (component == 2) {
pTitle = [self.fontColor objectAtIndex:row];
(void)pickerView:(UIPickerView *)pickerView
didSelectRow:(NSInteger)row
inComponent:(NSInteger)component
NSString *fontname =
NSLog(@"row number is %d",row);
if (component == 0) {
fontname = [self.fontNames objectAtIndex:row];
[textLabel setFont:[UIFont fontWithName:fontname size:currentFontSize]];
currentFontName =
[self.textInfoDic setObject:fontname forKey:@"currentFontName"];
if (component == 1) {
fontsize =[[self.fontSize objectAtIndex:row]floatValue];
[textLabel setFont:[UIFont fontWithName:currentFontName size:fontsize]];
currentFontSize =
NSString *cFontSize =
[NSString stringWithFormat:@"%f",fontsize];
[self.textInfoDic setObject:cFontSize forKey:@"currentFontSize"];
if(component == 2)
currentFontColor =
[self.fontColor objectAtIndex:row];
if ([currentFontColor isEqualToString:@"blue"])
textLabel.textColor = [UIColor blueColor];
if ([currentFontColor isEqualToString:@"black"])
textLabel.textColor = [UIColor blackColor];
if ([currentFontColor isEqualToString:@"grown"])
textLabel.textColor = [UIColor grayColor];
if ([currentFontColor isEqualToString:@"red"])
textLabel.textColor = [UIColor redColor];
if ([currentFontColor isEqualToString:@"green"])
textLabel.textColor = [UIColor greenColor];
[self.textInfoDic setObject:currentFontColor forKey:@"currentFontColor"];
#pragma mark -
#pragma mark UIPickerViewDataSource methods
(NSInteger)numberOfComponentsInPickerView:(UIPickerView
*)pickerView
(NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
NSInteger RC
switch (component) {
RCount = [self.fontNames count];
NSLog(@"fontname number is%d",RCount);
RCount = [self.fontSize count];
NSLog(@"fontSize number is%d",RCount);
RCount = [self.fontColor count];
NSLog(@"fontColor number is%d",RCount);
// The designated initializer. Override to perform setup that is
required before the view is loaded.
(id)initWithNibName:(NSString *)nibNameOrNil
bundle:(NSBundle
*)nibBundleOrNil {
& & self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
& & if (self) {
& & // Custom
initialization
self.textInfoDic =
[[NSMutableDictionary alloc]init];
self.fontNames = [[NSArray alloc]init];
self.fontNames =
familyNames];
self.fontSize =
[[NSArray alloc]initWithObjects:@"8",@"10",@"14",@"16",@"18",@"20",@"22",@"24",@"26",@"28",nil];
self.fontColor =
[[NSArray alloc]initWithObjects:@"black",@"grown",@"green",@"blue",@"red",nil];
NSLog(@"font name is %@",self.fontNames);
NSLog(@"font size is %@",self.fontSize);
NSLog(@"font color is %@",self.fontColor);
//load a text label
textLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,
textLabel.text
= @"A Happy Day And our
[self.view
addSubview:textLabel];
NSLog(@"textlabel set %@",textLabel);
[textLabel release];
//load a picker
textInfoPicker = [[UIPickerView alloc]initWithFrame:CGRectMake(0,
textInfoPicker.delegate = self;
textInfoPicker.dataSource = self;
textInfoPicker.showsSelectionIndicator = YES;
[self.view
addSubview:textInfoPicker];
NSLog(@"picker set %@",textInfoPicker);
[textInfoPicker release];
& return self;
// Implement viewDidLoad to do additional setup after loading the
view, typically from a nib.
(void)viewDidLoad {
viewDidLoad];
[setTextBtn addTarget:self
action:@selector(storeAndSet) forControlEvents:UIControlEventTouchUpInside];
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。22:00 提问
新手求教,ios开发遇到的NSInvalidArgumentException问题
代码:-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSString *oldPhotoKey=[self.diary photoKey];
if(oldPhotoKey){
[[ImageStore defaultImageStore]deleteImageForKey:oldPhotoKey];
UIImage *Image=[info objectForKey:UIImagePickerControllerOriginalImage];
CFUUIDRef newUniqueID=CFUUIDCreate(kCFAllocatorDefault);
CFStringRef newUniqueIDString=CFUUIDCreateString(kCFAllocatorDefault, newUniqueID);
NSString *photoKey1=(__bridge NSString *)newUniqueIDS
self.diary.photoKey=photoKey1;
CFRelease(newUniqueIDString);
CFRelease(newUniqueID);
[[ImageStore defaultImageStore] setImage:Image forKey:self.diary.photoKey];
[self.picture setImage:Image];
[self dismissViewControllerAnimated:YES completion:nil];
debug: 13:34:53.827 Mydiary[1119:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'
键值明明已经附值了,为何显示没有呢?
按赞数排序
打个断点看看就知到加没加上了
其他相似问题
相关参考资料主题 : 如何让UIPickerView加载后就自动选择到某一行值
级别: 新手上路
可可豆: 40 CB
威望: 40 点
在线时间: 9(时)
发自: Web Page
如何让UIPickerView加载后就自动选择到某一行值&&&
我想在把从数据库中取出的某一值自动显示在uipickerview中,而不是默认选中的第一行值。我试过了在 viewDidLoad 中添加如下代码:int value = [arrayNo indexOfObject: someString];        //someString 是我想让uipicerview自动选中的值[pickerView selectRow: value+1 inComponent:0 animated:NO];但是没起作用,uipickerview仍然一直选中第一行。请教各位~~~ 这里应该怎么做?谢谢(:
级别: 骑士
UID: 60059
可可豆: 2431 CB
威望: 2045 点
在线时间: 149(时)
发自: Web Page
设断点调试一下,看看value是不是想象的值
级别: 新手上路
可可豆: 40 CB
威望: 40 点
在线时间: 9(时)
发自: Web Page
引用 引用第1楼yuzhouwww于 14:44发表的&&:设断点调试一下,看看value是不是想象的值 恩value值是对的
级别: 骑士
UID: 60059
可可豆: 2431 CB
威望: 2045 点
在线时间: 149(时)
发自: Web Page
那个value为什么要+1啊,不过还是不明白为什么还是第一行
级别: 新手上路
可可豆: 40 CB
威望: 40 点
在线时间: 9(时)
发自: Web Page
引用 引用第3楼yuzhouwww于 10:20发表的&&:那个value为什么要+1啊,不过还是不明白为什么还是第一行 因为value=0的时候选中的是第一行是啊我也不知道为什么不行。。
级别: 骑士
可可豆: 1796 CB
威望: 1796 点
在线时间: 340(时)
发自: Web Page
手动设置一下&&先别用value 看看到底是不是&&value的事&&如果不是&&在找 其他原因&&是不是 语句的顺序有问题&&一步一步来&&别急&& !
级别: 骑士
UID: 60059
可可豆: 2431 CB
威望: 2045 点
在线时间: 149(时)
发自: Web Page
引用 引用第4楼zhna123于 00:25发表的&&:因为value=0的时候选中的是第一行是啊我也不知道为什么不行。。....... 拜托,第一行就是0啊,那这样写会越界的!搞不好就是这个问题
级别: 新手上路
可可豆: 15 CB
威望: 15 点
在线时间: 25(时)
发自: Web Page
你把这行代码放在加载pickerview之后
关注本帖(如果有新回复会站内信通知您)
3*3+1 正确答案:10
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. J it only takes a minute:
So as the title said, I'm getting this error in my code. There's no output besides the usual (lldb) thing. The line it's pointing to is
0x10df051:
8(%edx), %edi0x10df051:
8(%edx), %edi
The code itself is
DeltaViewController *deltaview = [[DeltaViewController alloc] initWithNibName:@"DeltaViewController" bundle:nil];
It happened when I selected an object in my picker and it should add a subview.
22.1k217192
deltaview is DeltaViewController type, so it's a controller, not a view. After you've added it as a subview of self.view ([self.view addSubview:deltaview.view];), you might release the deltaview. Then whenever you sent a method (which is implemented in DeltaViewController) to deltaview, you'll get this EXC_BAD_ACCESS error of course.
A simple solution: Just declare deltaview (actually, it should be deltaViewController instead) as an iVar instead of local variable.
Well, here's a simple code snippet:
YourViewController.h:
@interface YourViewController : UIViewController
@property DeltaViewController *deltaViewC
YourViewController.m:
@implementation YourViewController
@synthesize deltaViewC
- (void)aM
- (void)dealloc {
self.deltaViewController = // set it to nil & release it after yourViewController dealloced.
[super dealloc];
- (void)aMethod {
DeltaViewController *deltaViewController = [[DeltaViewController alloc] initWithNibName:@"DeltaViewController" bundle:nil];
// ...(setup deltaViewController)
self.deltaViewController = deltaViewC // it'll retain deltaViewController
[deltaViewController release];
22.1k217192
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled

我要回帖

 

随机推荐