如何从左到右动画视图过渡(类似推视图).单击按钮时,视图应从左向右移动.所以请指导我并给出一些示例链接.
谢谢.
我以编程方式创建了10个按钮,并在按钮中设置了标题.现在我想动态增加按钮框架大小,它取决于文本.
我给出了一些条件并设置了帧大小.但是我如何设置确切的帧大小取决于文本(动态获取文本).
这是我的示例代码,
float x=0, y=0, w, h=20;
for(int i = 100; i < 110; i++)
{
btn = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
UIImage * img = [UIImage imageNamed:@"Round_Rect4.png"];
[btn setBackgroundImage:img forState:UIControlStateSelected];
titleString = [titleArray objectAtIndex:i-100]; // get button title
if([titleString length] <= 5)
{
w = 50;
btn.frame = CGRectMake(x,y,w,h);
x = x + 70;
}
if (([titleString length] >= 6) && ([titleString length] <=10))
{
w = 70;
btn.frame = CGRectMake(x,y,w,h);
x = x + 90;
}
if(([titleString length] …Run Code Online (Sandbox Code Playgroud) 我想将NSMUtableDictionary值复制到另一个NSMutableDictioary中.我怎样才能做到这一点?
我的代码是,
PersonClass.h file:
NSMutableDictionary *tempDictionary;
@property (nonatomic, retain) NSMutableDictionary *tempDictionary;
PersonClass.m
@synthesize tempDictionary;
tempDictionary = [[NSMutableDictionary alloc] init];
-(PersonClass *) initWithPerson:(NSMutableDictionary *) feedDictionary
{
// get all the values in feedDictionary.
//Now i want copy of the details from feedDictionary into the tempDictionary
tempDictionary = feedDictionary; // Doesn't copy.
}
Run Code Online (Sandbox Code Playgroud)
我想访问person类的tempDictionary值.那我如何从feedDictionary复制到tempDictionary.请帮帮我.
谢谢.
我是iphone开发的新手,现在我想在所有视图控制器中访问字符串变量,但我知道在委托方法中声明变量,但我无法访问它,请帮助我.
Mainviewcontroller - > Viewcontroller1 _--> viewcontroller2 - > viewcontroller3 - > subwebview.
我创建了一个主视图控制器,子视图类是Viewcontroller1,viewcontroller2,viewcontroller3.subwebview是所有三个viewcontrollers的子类(Viewcontroller1,Viewcontroller2,Viewcontroller3).
现在我想从所有viewcontrollers(Viewcontroller1,Viewcontroller2,Viewcontroller3)访问subwebview中的字符串变量,如何访问SUBWEBVIEW中的字符串变量.
我正在使用Rss提要阅读器并检索数据.
我已经在我的字符串变量中声明了所有视图控制器,比如
NSString * currentElement;
NSMutableString * currentTitle, * currentDate, * currentSummary, * currentLink;
Run Code Online (Sandbox Code Playgroud)
我被困在这里.我无法继续.请帮助我.
谢谢.
我正在使用通用应用程序.现在我想在iPAD的视图控制器中创建三个表视图.我有三个独立的视图控制器与XIB.So我如何在主控制器中添加另外两个表视图作为子视图.请给我一些示例应用程序和链接.在我的应用程序中,我有三个视图控制器并添加一个子视图作为表视图(而不是UITableViewController).在单击第一个表视图数据时,它导航到第二个表并单击第二个表视图数据,它将导航到第三个表视图.
Hierarchy:
MainViewController:
--SubTableView1
--SubTableView2
Run Code Online (Sandbox Code Playgroud)
见下图,

请帮帮我.
谢谢!!
我创建了三个按钮,并为正常状态和选定状态设置背景图像.单击按钮时,将一个图像更改为选定状态.但是当滚动表视图时,不保留所选图像(先前选择的单元格),这意味着它是正常状态.
我的代码是,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
likeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *likeSelectedImage = [UIImage imageNamed:@"like.png"];
//set image as background for button in the normal state
[likeBtn setBackgroundImage:likeSelectedImage forState:UIControlStateNormal];
[likeBtn addTarget:self action:@selector(likeAction:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:likeBtn];
}
Run Code Online (Sandbox Code Playgroud)
我的按钮动作是,
-(void) likeAction : (id) sender
{
UIImage *likeSelectedImg = [UIImage imageNamed:@"like-selected.png"];
UIImage *likeImg = [UIImage imageNamed:@"like.png"];
if ([sender isSelected]) {
[sender setImage:likeImg forState:UIControlStateNormal];
[sender setSelected:NO];
}else {
[sender setImage:likeSelectedImg forState:UIControlStateSelected];
[sender setSelected:YES];
}
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,当我滚动表视图单元格时,不保留先前选择的图像状态.因为cellForRowAtIndex方法已经反复调用,当我滚动表时.所以它会自动设定"[likeBtn setBackgroundImage:likeSelectedImage forState:UIControlStateNormal];".如何避免这个问题?那么请帮帮我吧?谢谢!
我想在组表视图单元格中创建一个文本字段.如果我在单元格中创建一个文本字段,则在所有分组的表格视图单元格中重叠文本字段.我不知道是怎么回事.所以我想在分组表视图单元格中创建一个文本字段(不是所有单元格).我怎样才能做到这一点?有可用的示例代码吗?
这是我的示例代码,
if(indexPath.section == 0)
{
if(indexPath.row == 0)
{
UITextField * lastname = [[UITextField alloc] initWithFrame:CGRectMake(120, 5, 150, 35)];
lastname.tag = titleTag2;
[cell.contentView addSubview:lastname];
lastname.delegate = self;
lastname.returnKeyType = UIReturnKeyDefault;
}
}
Run Code Online (Sandbox Code Playgroud) 我想为单元格设置背景图像.我已经在表格视图中为单元格设置了背景图像.但是我想在表格视图单元格中为背景图像设置两个图像.我想为背景设置备用单元格,
喜欢,
Image1- Cell 1, Cell 3, Cell 5, Etc.,
Imgae-2- Cell 2, Cell 4,Cell 6, Etc.,
Run Code Online (Sandbox Code Playgroud)
请指导我并给我一些示例链接.
谢谢!
我创建了一个自定义视图,并添加了一个Web视图作为该自定义视图的子视图.我已经以编程方式创建了一个导航栏.现在我想在该视图中创建一个左或右导航栏按钮.
navigBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
navigBar.tintColor = [UIColor blackColor];
[self.view addSubview:navigBar];
UIBarButtonItem *homeButton = [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonSystemItemAction target:self action:@selector(homeButtonAction)];
navigBar.rightBarButtonItem = homeButton; // it's not supports
Run Code Online (Sandbox Code Playgroud)
如何在自定义导航栏中创建导航栏项目?,我想删除自定义视图.所以请帮帮我!
谢谢.
我是iPhone开发的新手.我想在所有类方法中访问一个字符串变量,我想全局访问该字符串.我怎样才能做到这一点?
请帮帮我.
我有数据到可变数组和数组的值是,
{ "20", "40", "50","60", "70"}.
Run Code Online (Sandbox Code Playgroud)
我已将字符串值存储到数组中.
现在我想要数组的总值.结果是:240
谢谢!
我想用Haversine公式计算两个地方之间的距离.实际上我有两个地方的纬度和经度值.现在我想用Haversine公式计算那些地方之间的距离.
对于Eg:
First Place:
"lat" : 12.97159870,
"lng" : -77.59456270
Second Place:
"lat" : 9.915996999999999,
"lng" : -78.1218470
},
Run Code Online (Sandbox Code Playgroud)
现在我想用Haversine Formula计算距离.
请帮帮我.谢谢!
iphone ×11
uitableview ×4
declaration ×2
objective-c ×2
add ×1
animation ×1
cocoa-touch ×1
dynamic ×1
formula ×1
haversine ×1
ipad ×1
scope ×1
uibutton ×1
uiview ×1
width ×1