ios怎么在cell present

ios怎么在cell present,第1张

present和push都是需要controller才能完成跳转。

所以就有几种方法可以用:

1、把你要跳转的意图传给tableview所在的controller。可以用通知,block,代理方法,只要能把消息传出去就行。在tableview所在的controller进行跳转

2、获取cell所在的controller,在cell中进行跳转。

- (UIViewController )getSuperController{

UIViewController vc = [[UIViewController alloc]init];

for (UIView next = [self superview]; next; next = nextsuperview) {

UIResponder nextResponder = [next nextResponder];

if ([nextResponder isKindOfClass:[UIViewController class]]) {

vc = (UIViewController)nextResponder;

break;

}

}

return vc;

}

UIViewController vc = [self getSuperController];

用获得的vc进行跳转。

望采纳!

一般来说,在UITableView中,当用户滚动到某个没有出现的cell时,cellSortForRowAtIndexPath才会调用,才会加载此cell并显示出来。如果想让某个没有出现的cell提前加载,可以在控制器的viewDidLoad()方法里,手动调用UITableView的reloadData方法,同时实现tableView:cellForRowAtIndexPath方法,就可以把想要提前加载并显示的cell加载出来并显示出来了。同时,可以通过tableView:willDisplayCell方法实现对将要出现的cell的性能优化,为其添加相应的功能。

1、先把Cell的头文件import进来

2、[tableview_main registerNib:[UINib nibWithNibName:@"UserCallDealTableViewCell" bundle:nil] forCellReuseIdentifier:@"UserCallDealTableViewCellMark"];

使用这个方法注册自定义Cell tableview_main就是当前tableview实力化对象,然后UserCallDealTableViewCell这个字符串就是xib的名称,UserCallDealTableViewCellMark是重用机制的标记,配合等一下的代理方法使用

3、最后在代理方法控制自定义cell

-(UITableViewCell)tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath )indexPath{

NSString identification = @"UserCallDealTableViewCellMark";

UserCallDealTableViewCell cell = [tableview_main dequeueReusableCellWithIdentifier:identification];

if (cell != nil) {

NSDictionary dict_tmp = arry_dataSource[indexPathrow];

cell->label_doctor_nametext = dict_tmp[@"doctorName"];

cell->label_hosptialtext = dict_tmp[@"hospitalName"];

if ([dict_tmp[@"sstatus"] isEqualToString:@"S"]) {

cell->label_statustext = @"预约成功";

}

else{

cell->label_statustext = @"预约失败";

}

NSString string_date = @{@"0":@"上午",@"1":@"下午"}[dict_tmp[@"timeq"]];

NSDateFormatter formatter = [[NSDateFormatter alloc]init];

[formatter setDateFormat:@"yyyy-MM-dd"];

NSDate date_tmp = [formatter dateFromString:dict_tmp[@"date"]];

[formatter setDateFormat:[NSString stringWithFormat:@"MM月dd日 EEEE %@ mm:HH",string_date]];

cell->label_infotext = [formatter stringFromDate:date_tmp];

return cell;

}

return [UITableViewCell new];//这个地方我建议不要返回nil因为可能会导致崩溃

}

UICollectionView 和 UICollectionViewController 类是iOS6 新引进的API,用于展示集合视图,布局更加灵活,可实现多列布局,用法类似于UITableView 和 UITableViewController 类。

使用UICollectionView 必须实现UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout这三个协议。

下面先给出常用到的一些方法。(只给出常用的,其他的可以查看相关API)

#pragma mark -- UICollectionViewDataSource

//定义展示的UICollectionViewCell的个数

-(NSInteger)collectionView:(UICollectionView )collectionView numberOfItemsInSection:(NSInteger)section

{

return 30;

}

//定义展示的Section的个数

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView )collectionView

{

return 1;

}

//每个UICollectionView展示的内容

-(UICollectionViewCell )collectionView:(UICollectionView )collectionView cellForItemAtIndexPath:(NSIndexPath )indexPath

{

static NSString CellIdentifier = @"GradientCell";

UICollectionViewCell cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];

cellbackgroundColor = [UIColor colorWithRed:((10 indexPathrow) / 2550) green:((20 indexPathrow)/2550) blue:((30 indexPathrow)/2550) alpha:10f];

return cell;

}

#pragma mark --UICollectionViewDelegateFlowLayout

//定义每个UICollectionView 的大小

- (CGSize)collectionView:(UICollectionView )collectionView layout:(UICollectionViewLayout)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath )indexPath

{

return CGSizeMake(96, 100);

}

//定义每个UICollectionView 的 margin

-(UIEdgeInsets)collectionView:(UICollectionView )collectionView layout:(UICollectionViewLayout )collectionViewLayout insetForSectionAtIndex:(NSInteger)section

{

return UIEdgeInsetsMake(5, 5, 5, 5);

}

#pragma mark --UICollectionViewDelegate

//UICollectionView被选中时调用的方法

-(void)collectionView:(UICollectionView )collectionView didSelectItemAtIndexPath:(NSIndexPath )indexPath

{

UICollectionViewCell cell = (UICollectionViewCell )[collectionView cellForItemAtIndexPath:indexPath];

cellbackgroundColor = [UIColor whiteColor];

}

//返回这个UICollectionView是否可以被选择

-(BOOL)collectionView:(UICollectionView )collectionView shouldSelectItemAtIndexPath:(NSIndexPath )indexPath

{

return YES;

}

ios 怎么获取一个view的位置

打开appstore进入应用,右上角的分享按钮(从右往左数第二个),拷贝连接即可。如下图:

如何获取一个view在布局中的位置

public View getViewByPosition(int pos, ListView listView) {

final int firstListItemPosition = listViewgetFirstVisiblePosition();

final int lastListItemPosition = firstListItemPosition + listViewgetChildCount() - 1;

if (pos < firstListItemPosition || pos > lastListItemPosition ) {

return listViewgetAdapter()getView(pos, null, listView);

} else {

final int childIndex = pos - firstListItemPosition;

return listViewgetChildAt(childIndex);

}

} 已解决,通过这个方法就可以实现了获取item中的view

如何获取一个uicollectionviewcell的位置

UICollectionViewCell cell = (UICollectionViewCell )[collectionView

cellForItemAtIndexPath:indexPath];一句话就能获取到点击cell的frame,十分好用,同样适用于tableView。

ios中怎么获取collectionview中cell的位置

你在点击cell的时候调用 - (void)performSegueWithIdentifier:(NSString )identifier sender:(id)sender ;

那不是有个sender嘛,你可以给它传值。

然后在-(void)prepareForSegue:(UIStoryboardSegue )segue sender:(id)sender 里的sender,就是你刚传的那个值。

Flash中怎么通过代码来获取一个左上、右下的位置,_x和_y只能获取图像原点的位置。

设左上坐标(x1,y1),右下坐标(x2,y2),原点坐标(x0,y0),元件名称为mcPic,则:

x1 = mcPicx - mcPicwidth/2

y1 = mcPicy - mcPicheight/2

x2 = mcPicx + mcPicwidth/2

y2 = mcPicy + mcPicheight/2

x0 = mcPicx

y0 = mcPicy

怎样通过qq获取一个人的位置信息

除了使用者本人定位,其他人无法获取,这属于隐私保护

android 怎么获取ActionBar上某个menu的位置

Android 30以上的手机默认是不显示溢出菜单的,那如何强制在Android 44以下的手机显示溢出菜单呢?可以使用以下方法:

[java] view plaincopy在CODE上查看代码片派生到我的代码片

强制actionbar显示overflow菜单

适配类似魅族手机无法显示溢出菜单的解决方案

上面已经解决了如何在Android 44以下的手机强制显示溢出菜单,下面来解决一些奇葩手机无法显示溢出菜单的问题。为什么魅族手机无法显示,了解到的是魅族没有所谓的actionbar,它们称为 artbar,看来是魅族的工程师把官方的actionbar进行了修改。一个字,坑!不过小巫想到了一个解决办法,我们每部手机都有自己的手机品牌,我们可以针对这些奇葩手机进行适配,溢出菜单我们就使用popupwindow来替代。

MATLAB中,怎么获取一个向量中最大的N个元素,并获取它们所在的位置

v=rand(1,5)

[mv mi]=max(v)

%mv为最大值,mi为最大值索引,v(mi)=mv

[sv si]=sort(v,2,'descend')

%si为从大到小的序列,比如要去最大的3个数就是v(si(1:3))

ios地图定位怎么获取两个点之间的位置

通常我们在手机端打开百度地图后,客户端会自动对我们所处的位置进行定位的。如果没有进行定位的话,你可以点击地图页面的左下角的圆形图标,见下图红色框中所示,点击之后会自动更新,并且显示定位的地址信息。

VBS中如何获取一个数组中最大值的位置

以下VBS脚本可以实现这个功能:

Public Function getArrMaxValueIndex(ByVal arr)

Dim ix, ixMax

ixMax = 0

For ix = 1 To UBound(arr)

If ( arr(ixMax) < arr(ix) ) Then

ixMax = ix

End If

Next

getArrMaxValueIndex = ixMax

End Function

'Define array and index for max entry

Dim arr, ixMax

'Initialize the array

arr = Array(4, 1, 8, 6, 3,6)

'Get the index of the max value

ixMax = getArrMaxValueIndex(arr)

'Print result

MsgBox "Max value: " & arr(ixMax) & " was found at " & ixMax & " index"

以上就是关于ios怎么在cell present全部的内容,包括:ios怎么在cell present、ios如何让某个没有出现的cell提前加载、iOS开发,怎么注册xib自定义的cell等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9667960.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存