小编use*_*721的帖子

如何在导航栏上更改UIBarButtonItem的字体颜色/文本颜色

我按照下面的方式在导航栏中添加了一个条形按钮

UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithTitle:@"CANCEL" style:UIBarButtonItemStyleBordered target:self action:@selector(goToPreviousView)];
    self.navigationItem.leftBarButtonItem = cancel;
Run Code Online (Sandbox Code Playgroud)

现在我想在RED Color中显示Text"CANCEL".

我的意思是我需要更改条形按钮项目上文本,而不是按钮的色调颜色.

怎么做?

iphone xcode objective-c ipad ios

26
推荐指数
5
解决办法
3万
查看次数

将图像添加到UITextView

在我的应用程序中,我UITextView在文本视图下方有一个按钮,可以UITextView在编辑时插入照片.

我的要求是用户用户能够在其中编辑文本,并在需要时插入图像.

与StackOverflow的应用程序类似UITextView:

在此输入图像描述

iphone objective-c uitextview uiimageview ipad

12
推荐指数
2
解决办法
2万
查看次数

如何在具有从DataBase获取内容的UITableView中实现按字母顺序排列的标题

直到现在我已经UITableView通过填充数据库中的内容来实现

通过从sqlite数据库中检索数组

storedContactsArray = [Sqlitefile selectAllContactsFromDB];

所以没有多个部分,节标题和返回storedContactsArray.count行数.

现在我需要在表视图中填充相同的数据,但是按字母顺序在Alpabetical部分中设置数据.

我试过了

alphabetsArray =[[NSMutableArray alloc]initWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z",nil];


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [alphabetsArray count];
}

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
      return alphabetsArray;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
      return [alphabetsArray objectAtIndex:section];
}
Run Code Online (Sandbox Code Playgroud)

需要如下

但是在numberOfRowsInSection的情况下它失败了,因为storedContactsArray最初没有接触

发生错误: -[__NSArrayM objectAtIndex:]: index 25 beyond bounds for empty array

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  return [[storedContactsArray objectAtIndex:section] count]
}
Run Code Online (Sandbox Code Playgroud)

任何建议使用完整链接请

sqlite iphone objective-c uitableview

3
推荐指数
1
解决办法
8249
查看次数

如何根据原始图像大小比率设置UIimageview宽度

在我的iPhone应用程序中,我需要在图像视图中设置图像.

图像视图高度始终为100像素.

we need to set the width of the image view with respect to the original image scale ratio.

即每个假设宽度X图像的高度为300x400(原始)(4x3)

我们显示的图像视图图像大小为75X100

图像宽度X高度为512x512(原始)(1x1)

我们显示的图像视图图像大小为100X100

宽度X图像的高度为128 x 256(原始)(1x2)

我们显示的图像视图图像大小为50X100

in all those cases image view height 100pixel should be same, but the width need to varie with respect to the image ratio.

最后,图像视图应位于视图的中心

如何实现它

iphone objective-c uiimageview uiimage

1
推荐指数
1
解决办法
1883
查看次数