有没有办法自定义所选分段的颜色UISegmentedControl?
我找到了segmentedController.tintColor属性,它可以让我自定义整个分段控件的颜色.问题是,当我为tintColor属性选择亮色时,所选的段几乎变得不可识别(其颜色几乎与分段控件的其余部分相同,因此很难区分选定和未选择的段).所以我不能使用任何好的亮色进行分段控制.解决方案将是选定的段颜色的一些单独的属性,但我找不到它.有没人解决这个问题?
我有主要的UIView,我在那里显示不同的数据.然后我放了一个按钮,显示如下子视图:
- (IBAction) buttonClicked:(id)sender
{
UIView *newView = [[UIView alloc] initWithFrame:CGRectMake(25,25,50,20)];
UILabel *newLabel = [[UILabel alloc] initWithFrame:CGRectMake(25,25,50,25)];
newLabel.text = @"some text";
[newView addSubview:newLabel];
[self.view addSubview:newView];
[newLabel release];
[newView release];
}
Run Code Online (Sandbox Code Playgroud)
newView看起来很好,但它不会以任何方式动画,它只会立即出现.当newView出现时,如何添加某种动画?像缩放或向下滑动或类似的东西.有一些简单的代码吗?
当我在Interface Builder中创建UITextField时,我可以访问它的事件选项卡,其中包含值已更改,触摸取消,触摸拖动等事件.我可以将自己的方法分配给每个事件.当我使用alloc编程创建UITextField时,我该怎么做呢?
我创建了NSMutableUrlRequest来将数据发送到服务器,向其中添加所有必需的字段,然后添加用于发送的字符串,如下所示:
[theRequest setHTTPBody:[postString dataUsingEncoding: NSUTF8StringEncoding]];
Run Code Online (Sandbox Code Playgroud)
postString是通常的NSString。
问题是,当我在服务器上收到此请求时,所有加号(+)从http正文中消失。因此,如果我在iPhone上安装了“ abcde + fghj”,则在服务器上会收到“ abcde fghj””。
使用dataUsingEncoding:NSUTF8StringEncoding会不会是一些编码问题?还是某些NSMutableUrlRequest剥离功能?我该怎么做才能使其停止剥离加号?我需要在服务器端接收UTF8字符串。
我有一个表,我有cellForRowAtIndexPath委托,我在该方法中创建了UITableViewCell的实例,我将返回.在cellForRowAtIndexPath的某处,我还将UIButton添加到该单元格的cell.contentView.一切正常,直到我选择带有按钮的单元格.单元格将颜色更改为蓝色(可以),uibutton也将颜色更改为蓝色.现在,如果我点击所选单元格内的UIButton,它就会消失!哇,这很奇怪,我该如何解决?当我点击它时,我希望选定单元格内的UIButton保持不变.
编辑:包含我的cellForRowAtIndexPath实现
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *sectionsTableIdentifier = @" sectionsTableIdentifier ";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: sectionsTableIdentifier];
for (UIView *view in cell.contentView.subviews)
[view removeFromSuperview];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero
reuseIdentifier: sectionsTableIdentifier] autorelease];
}
CGRect newIconRect = CGRectMake(276, 40, 29, 29);
UIButton *newIcon = [[UIButton alloc] initWithFrame:newIconRect];
[newIcon setImage:[UIImage imageNamed:@"mynewicon.png"] forState:UIControlStateNormal];
[cell.contentView addSubview:newIcon];
[newIcon release];
return cell;
}
Run Code Online (Sandbox Code Playgroud) 我有一个方法,动画其中一个子视图,UIWindow然后将其从UIWindow使用中删除removeFromSuperview.但是,当我把removeFromSuperview动画块后,动画从来没有显示,因为removeFromSuperview消除了UIView从UIWindow动画播放:-(之前,我怎样才能延缓removeFromSuperview所以播放动画,然后再子视图被删除?我试图[NSThread sleepForTimeInterval:1];动画块后,但没有有理想的效果,因为动画因某种原因也会睡觉.
我的这个方法的代码:
- (void) animateAndRemove
{
NSObject *mainWindow = [[UIApplication sharedApplication] keyWindow];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
UIView *theView = nil;
for (UIView *currentView in [mainWindow subviews])
{
if (currentView.tag == 666)
{
currentView.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.0];
theView = currentView;
}
}
[UIView setAnimationTransition: UIViewAnimationTransitionNone forView:theView cache:YES];
[UIView commitAnimations];
//[NSThread sleepForTimeInterval:1];
[theView removeFromSuperview];
}
Run Code Online (Sandbox Code Playgroud) iphone ×6
animation ×2
uiview ×2
colors ×1
events ×1
nsdata ×1
nsstring ×1
uibutton ×1
uitableview ×1
uitextfield ×1