首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

UIActionSheet平添UIPickerView

2012-07-02 
UIActionSheet添加UIPickerView.?今天写了一个ActionSheet添加的UIPickerView的程序,搜索了很多的资料- (v

UIActionSheet添加UIPickerView.

?今天写了一个ActionSheet添加的UIPickerView的程序,搜索了很多的资料

- (void)configurePickersAndActionSheets {    CGRect pickerFrame;    if ((self.interfaceOrientation == UIInterfaceOrientationPortrait) ||        (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) {        pickerFrame = CGRectMake(0, 180, 0, 0);    } else {        pickerFrame = CGRectMake(0,180,480,200);    }    self.areaActionSheet = [[[UIActionSheet alloc] initWithTitle:@"Area" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Use",NULL] autorelease];    self.areaPicker = [[[UIPickerView alloc] initWithFrame:pickerFrame] autorelease];    self.areaPicker.delegate = self;    self.areaPicker.showsSelectionIndicator = YES;    [self.areaActionSheet addSubview:areaPicker];}
上面的代码就是横屏和纵屏的大小设置 
 if ((self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||        (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)) {        [actionSheet setBounds:CGRectMake(0, 0, 480, 480)];    } else {        [actionSheet setBounds:CGRectMake(0, 0, 320, 618)];    }
此处用来设置actionsheet的大小  
具体的添加PickerView如下:
UIActionSheet?*menu?=?[[UIActionSheet alloc]?initWithTitle:[currentData objectAtIndex:0]?
delegate:selfcancelButtonTitle:@"Done"destructiveButtonTitle:@"Cancel"otherButtonTitles:nil];

?

UIPickerView?[[UIPickerView ? alloc]initWithFrame(0,40,480,200)];

pickerView.delegate?=?self;pickerView.showsSelectionIndicator?=?YES; ? ??

[menu addSubview];[menu showInView];[menu setBounds(0,0,480, 320)];

[pickerView release];[menu release];

?

OK这个就完成了ActionSheet的操作,可能你还会有一个问题就是在UIPickerView如何设置显示下拉框的

字体大小,即改变显示数组中的字体大小:?

需要重写实现如下方法?

- (viewForRow:(? forComponent:( ? reusingView:(

pickerLabel = [[pickerLabel.?

pickerLabel.?? ?}

?? ? ??pickerLabel.?? }

?? pickerLabel.}

return?0;

}

?

?

这样就解决字体大小的问题了.?

热点排行