使用以下代码创建视图.
- (void)loadView {
paintView=[[UIView alloc]initWithFrame:CGRectMake(0, 50, 320, 430)];
[paintView setBackgroundColor:[UIColor yellowColor]];
self.view = paintView;
[paintView release];
Run Code Online (Sandbox Code Playgroud)
但我的问题是整个屏幕填充黄色,但我想要指定的框架.我在基于视图的应用程序中创建此视图..我做错了什么,Overridind原始视图?
我的应用程序包含两个数组(即productArray和priceArray)并在单元格上传递一个数组的值.text.eltaillabel.text上的textlabel.text和其他数组.工作正常.现在我想在升序价格表中对uitableview进行排序.请指导我怎么做..这是我的代码..
#import <UIKit/UIKit.h>
@interface RootViewController : UITableViewController {
NSMutableArray *productArray;
NSMutableArray *priceArray;
}
@property(nonatomic,retain)NSMutableArray *productArray;
@property(nonatomic,retain)NSMutableArray *priceArray;
@end
#import "RootViewController.h"
@implementation RootViewController
@synthesize productArray,priceArray;
- (void)viewDidLoad {
[super viewDidLoad];
productArray=[[NSMutableArray alloc]initWithObjects:@"Apple",@"iphone",@"ipod",@"ipad",nil];
priceArray=[[NSMutableArray alloc]initWithObjects:@"4000",@"2000",@"100",@"1000",nil];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
#pragma mark -
#pragma mark Table view data source
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return …Run Code Online (Sandbox Code Playgroud) 我的数组在每个索引处包含(firstName,lastName,age).现在我想改变一个人在索引1的年龄.请指导如何做到这一点.这是我的代码.
- (void)viewDidLoad {
[super viewDidLoad];
productArray=[[NSMutableArray alloc]init];
PersonDetail *personObj = [[PersonDetail alloc] init];
personObj.firstName = @"Adeem";
personObj.lastName = @"Basraa";
personObj.age = @"5";
[productArray addObject:personObj];
[personObj release];
PersonDetail *personObj = [[PersonDetail alloc] init];
personObj.firstName = @"Ijaz";
personObj.lastName = @"Ahmed";
personObj.age = @"10";
[productArray addObject:personObj];
[personObj release];
PersonDetail *personObj = [[PersonDetail alloc] init];
personObj.firstName = @"Waqas";
personObj.lastName = @"Ahmad";
personObj.age = @"15";
[productArray addObject:personObj];
[personObj release];
Run Code Online (Sandbox Code Playgroud)
}