我想用多种颜色填写UIView背景.我想将它用作各种状态栏,因此如果完成1/2必要步骤,则UIView背景将为1/2绿色和1/2红色.当用户完成更多步骤(比如2/3)时,更多的UIView背景变为绿色(在这种情况下为2/3).
我猜我需要覆盖
-(void) drawREct: (CGRect) rect
Run Code Online (Sandbox Code Playgroud)
我想我会得到UIView,弄清楚它有多大,然后把它分成2个矩形然后填充那些矩形.
另一种选择是以编程方式添加2个UIViews,但我是IB的粉丝.
有可能像我想要的那样划分UIView吗?
谢谢
我试图在我的UITableView中创建更多的部分,我似乎无法搞清楚.我希望将"查看完整网站"和"视频"链接移动到他们自己的部分,并将这些单元格的高度更改为75.我可以创建一个新单元格,但我无法弄清楚如何正确定位它.
typedef enum { SectionHeader, SectionDetail } Sections;
typedef enum { SectionHeaderTitle, SectionHeaderDate, SectionHeaderURL, SectionHeaderEnclosure } HeaderRows;
typedef enum { SectionDetailSummary } DetailRows;
@implementation MediaDetailTableViewController
@synthesize item, dateString, summaryString, teachings;
#pragma mark -
#pragma mark Initialization
- (id)initWithStyle:(UITableViewStyle)style {
if ((self = [super initWithStyle:style])) {
}
return self;
}
#pragma mark -
#pragma mark View lifecycle
- (void)viewDidLoad {
// Super
[super viewDidLoad];
// Date
if (item.date) {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
self.dateString = …Run Code Online (Sandbox Code Playgroud) 我在Interface Builder中有一个UIButton,其初始标题为"Use Current Location".上面有一个UITextField,用户可以在其中键入地址或邮政编码.按钮和文本字段都是IBOutlets.
存在这些项的视图的视图控制器是a UITextFieldDelegate.在委托方法中,(BOOL)textFieldShouldReturn:(UITextField *)textField我想根据文本字段中是否包含任何内容来更改按钮标题.我的方法看起来像这样:
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
NSLog([textField text]);
if([[textField text] length] == 0)
{
NSLog(@"AAAAAAAAA");
[go setTitle:@"Use Current Location" forState:UIControlStateNormal];
}
else
{
NSLog(@"BBBBBBB");
[go setTitle:@"Use This Address" forState:UIControlStateNormal];
}
[textField resignFirstResponder];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
注意:go是UIButton.
此方法未按预期执行,但每次都记录正确的语句.按钮的标题不会改变.
任何帮助将特别感谢.
我有以下内容:

我想这样做,以便tableview停在"So"单元格,而不是在它下面的所有空白单元格(大计划是有一堆多项选择问题,如该图片中的那个,全部在在一个scrollview上彼此顶部).我猜我需要设置tableView的框架,但我想知道是否有一种简单的方法可以在运行时计算实现单元格的tableview部分的精确高度(图片中带有文本的部分).这很棘手,因为我做了它,以便每个单元格的高度可以改变以适应其中的文本量.有人有什么建议吗?
我有问题让我的导航控制器正常运行!如果我在RootViewController中单击表格的单元格,它似乎不是下一个ViewController.
错误消息读取
"应用程序试图将nil视图控制器推向目标."
所以我分配了一些错误的东西,我的猜测,我可能遗漏了我所遵循的书中的重要内容.
所以问题出现在我的RootViewController.m中:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UINavigationController *navigationController= [[UINavigationController alloc]init];
switch ([indexPath row]) {
case 0:
[navigationController pushViewController:kundeViewCon animated:YES];
break;
case 1:
[navigationController pushViewController:kalenderViewCon animated:YES];
break;
case 2:
[navigationController pushViewController:wunschViewCon animated:YES];
break;
}
}
Run Code Online (Sandbox Code Playgroud)
在我的AppDelegate.m中,我正在做以下事情来将RootViewController设置为NavigationController:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
// Navigation Controller
RootViewController *rootViewController = [[RootViewController alloc]init];
navigationController = [[UINavigationController alloc]initWithRootViewController:rootViewController];
self.window.backgroundColor = [UIColor whiteColor];
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible]; …Run Code Online (Sandbox Code Playgroud) 我在UIView上放置了4个UIImageView,并将它命名为
UIImageView myImg1 = [[UIImageView alloc] init];
UIImageView myImg2 = [[UIImageView alloc] init];
UIImageView myImg3 = [[UIImageView alloc] init];
UIImageView myImg4 = [[UIImageView alloc] init];
Run Code Online (Sandbox Code Playgroud)
我怎么能告诉编译器我刚刚触及UIImageView 1或UIImaveView 2.如果我只能使用UIImageView来完成这个任务,而不是按钮.请指导我这个问题.谢谢
我有一个UIAlertView(实际上有几个),-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex如果用户没有按下取消,我正在使用该方法触发一个动作.这是我的代码:
- (void)doStuff {
// complicated time consuming code here to produce:
NSString *mySecretString = [self complicatedRoutine];
int myInt = [self otherComplicatedRoutine];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"HERE'S THE STUFF"
message:myPublicString // derived from mySecretString
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Go On", nil];
[alert setTag:3];
[alert show];
[alert release];
}
Run Code Online (Sandbox Code Playgroud)
然后我想做的是以下内容:
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
if ([alertView tag] == 3) {
NSLog(@"%d: %@",myInt,mySecretString);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,这种方法不知道mySecretString或myInt.我绝对不想重新计算它们,我不想将它们存储为属性,因为-(void)doStuff很少(如果有的话)调用它们.有没有一种方法来此额外的信息添加到UIAlertView中,以避免重新计算或存储 …
我想制作一个具有两个不同XIB文件的通用应用程序.一个用于iPhone,一个用于iPad.他们使用相同的代码,只是不同的UI.我如何创建一个"通用"应用程序?
谢谢.
一旦用户点击触发操作的单元格,我想禁用用户交互,然后在操作完成后重新启用用户交互.谁能告诉我怎么做?
我想在Mint.com应用程序中创建一个类似于on的UI.它是带有UITableView单元格的UIScrollView吗?
注意每个块/单元格中有多个数据值.

iphone ×8
ios ×5
objective-c ×4
uitableview ×3
xcode ×2
cgrect ×1
cocoa-touch ×1
drawrect ×1
ipad ×1
uialertview ×1
uibutton ×1
uiview ×1
universal ×1
xcode4 ×1
xib ×1