Tag: 客观

如何在iOS中单击UIButton时将项目插入UITableView

我一直在用tableViews练习,但我不知道如何插入新项目,当一个button被点击。 这是我的: BIDViewController.h : #import <UIKit/UIKit.h> @interface BIDViewController : UIViewController // add protocols <UITableViewDataSource, UITableViewDelegate> //this will hold the data @property (strong, nonatomic) NSMutableArray *names; – (IBAction)addItems:(id)sender; @end BIDViewController.m : #import "BIDViewController.h" @interface BIDViewController () @end @implementation BIDViewController //lazy instantiation -(NSMutableArray*)names { if (_names == nil) { _names = [[NSMutableArray alloc]init]; } return _names; } […]

moveRowAtIndexPath – 在部分之间移动单元格

在我的UITableView我有这个说的关系 Department -< Employees (名称数组) 我为每个模型设置了自定义对象。 在我的moveRowAtIndexPath ,我可以移动到一个特定的部分; 但是,如果我试图在部分之间移动,它会崩溃。 这个想法是我想能够把“汤姆”从“销售”移动到“营销” #pragma mark – UITableView delegate -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { return [_objects count]; } -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { Department *department = [_objects objectAtIndex:section]; return [department.employees count]; } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellId" forIndexPath:indexPath]; // Configure the cell… Department […]

' – :无法识别的select器发送到实例' – 试图找出原因

我有一个UITableView自定义UILabel为标题和另一个字幕,以alignment文本到正确的。 我的数据来自Web服务,我parsing并存储在NSDictionary NSArray中。 一些标题或副标题可以是零/空文本。 为此,我把它放在try / catch中。 我的表中的一行使我的应用程序暗恋,我不明白为什么。 我认为他们之一(标题/副标题)返回作为NSDictionary但我做了我的对象类的日志打印,因为我的[UILabel text] ,似乎一切正常。 exception和堆栈跟踪: 2014-04-29 10:47:55.985 Cellular Radar[3226:60b] -[__NSDictionaryI length]: unrecognized selector sent to instance 0x16d007f0 2014-04-29 10:47:55.993 Cellular Radar[3226:60b] -[Home tableView:willDisplayCell:forRowAtIndexPath:], exception.reason: -[__NSDictionaryI length]: unrecognized selector sent to instance 0x16d007f0 2014-04-29 10:47:55.999 Cellular Radar[3226:60b] -[__NSDictionaryI length]: unrecognized selector sent to instance 0x16d007f0 2014-04-29 10:47:56.006 Cellular Radar[3226:60b] […]

平衡多行UILabel

当我创build一个NSLineBreakByWordWrapping与NSTextAlignmentCenter设置为NSTextAlignmentCenter , NSLineBreakByWordWrapping到NSLineBreakByWordWrapping和一个长文本,它分裂如下: +————————————+ | Text that does not fit on a single | | line | +————————————+ 但是我真正想要的是这样的: +————————————+ | Text that does not fit | | on a single line | +————————————+ 当然,我不想手动处理换行符。 我希望标签自动平衡线条,使其长度尽可能接近。

如何按照字母顺序将NSArray分割成UITableView部分

使用节标题的索引表时遇到问题。 目前我有右边的索引,并且节标题显示正确,标题只显示该部分内部是否有数据。 我遇到的问题是将NSArray分解成部分,所以我可以正确计算numberOfRowsInSections。 目前,我有正确数量的部分显示正确的标题,但所有的数据是在每个部分,而不是根据名称的第一个字母拆分。 这里是它目前的样子的截图: 所有的数据进入每个部分,每个5行。 部分(3)的数量是正确的 我的代码如下: – (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [firstLetterArray objectAtIndex:section]; } – (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { NSMutableSet *mySet = [[NSMutableSet alloc] init]; BRConnection *connection = nil; NSMutableArray *firstNames = [[NSMutableArray alloc] init]; for (connection in _connections) { [firstNames addObject:connection.firstName]; } firstNamesArray = firstNames; NSLog(@"%@", firstNamesArray); for ( NSString […]

标题和字幕之间的UITableViewCell空间-iOS

如何增加UITableViewCell中的标题和副标题之间的空白?

如何在UITableView静态单元格中dynamic更改单元格高度

我使用UITableViewController而不是detailView来显示一个实体的细节。 我在我的viewDidLoad方法中填充了PFQuery的一行数据。 我有一个单元格,我正在使用标签,我想根据NSString大小更改大小。 我检查了很多答案,但都与dynamic的indexPath有关,我有静态单元格。 My label显示完整的string,但我的细胞是固定的。 我怎样才能改变细胞的高度? 请帮我解决这个问题。 这是我的代码: – (void)viewDidLoad { [super viewDidLoad]; PFQuery *query = [PFQuery queryWithClassName:@"Entities"]; [query whereKey:@"name" equalTo:entityName]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { PFFile *thumbnail = [objects[0] objectForKey:@"image"]; detailsImageView.image = [UIImage imageNamed:@"loader.gif"]; detailsImageView.file = thumbnail; [detailsImageView loadInBackground]; detailLabel.numberOfLines = 0; // this label need dynamic height and […]

禁用自定义uibarbuttonitem图像的色调

我有我的导航控制器中的一些自定义栏button项目。 ( 最大化图像以更好地看到边界 ) 上面的截图是它应该是什么样子,以及我如何添加barbutton项目图像。 正如你所看到的,这个图标上面有一些较暗的渐变。 但是因为所有的图标都变成了有色,这个黑色的渐变也变成了白色,我的图标看起来非常模糊。 我只是把他们放入我的故事板。 有没有办法禁用这个barbuttonitems设色?

具有dynamic高度的UICollectionView错误

由于我一直在这个问题上挣扎了3天,并且已经问了两次,但是可能还不清楚,所以我决定调查这个问题,并且发现了这个问题。 我会显示整个简单的代码,所以任何人都可以重现的错误(iPad空气)。 我正在设置一个collectionViewstream布局,使布局子类化以获得单元格之间的恒定间距,这里是开始: TopAlignedCollectionViewFlowLayout *layout = [[TopAlignedCollectionViewFlowLayout alloc] init]; CGRect size = CGRectMake(0, 0, 900, 1200); self.GridView = [[UICollectionView alloc] initWithFrame:size collectionViewLayout:layout]; [self.GridView registerClass:[GridCell class] forCellWithReuseIdentifier:@"Cell"]; [self.GridView setDelegate:self]; [self.GridView setDataSource:self]; [self.view addSubview:self.GridView]; 然后设置我的委托是这样简单:( 高度是dynamic的 ) #pragma grid- main functions -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 80; } //cell size – […]

我想在UIView上绘制像苹果形状的自定义形状

我正在努力使苹果有一种进步的形象。 我有select使用.png图像,但我不能因为我必须填充苹果形状不同颜色取决于百分比状态..我使用UIView 绘制这种形状… 我想build议如何轻松画出苹果的那种形状? 而我们怎样才能用不同的颜色填充一半颜色?