任何人都知道为什么这个根View Controller's viewDidLoad在发布时被调用了两次?这让我疯了!
这是第一次到第一次的堆栈跟踪viewDidLoad:
#0 0x0000276a in -[RootViewController viewDidLoad] at RootViewController.m:71
#1 0x3097548f in -[UIViewController view]
#2 0x00002734 in -[RootViewController initWithCoder:] at RootViewController.m:39
#3 0x30ab5ce4 in -[UIClassSwapper initWithCoder:]
#4 0x30514636 in _decodeObjectBinary
#5 0x30514035 in _decodeObject
#6 0x30ab5a1d in -[UIRuntimeConnection initWithCoder:]
#7 0x30514636 in _decodeObjectBinary
#8 0x30515f27 in -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]
#9 0x305163b0 in -[NSArray(NSArray) initWithCoder:]
#10 0x30514636 in _decodeObjectBinary
#11 0x30514035 in _decodeObject
#12 0x30ab4dde in -[UINib instantiateWithOptions:owner:loadingResourcesFromBundle:]
#13 0x30ab6eb3 in -[NSBundle(NSBundleAdditions) loadNibNamed:owner:options:]
#14 0x308f85f1 in …Run Code Online (Sandbox Code Playgroud) 试图在我UICollectionView的标题中添加一个补充视图.我有问题让它工作.
我使用一个自定义UICollectionViewFlowLayout来返回一个contentSize总是至少比帧大1个像素(我使用的UIFreshControl只有UICollectionView滚动,并且设置collectionView.contentSize直接无效)并invalidateLayout打开sectionInsert和itemSize更改:
-(void)setSectionInset:(UIEdgeInsets)sectionInset {
if (UIEdgeInsetsEqualToEdgeInsets(super.sectionInset, sectionInset)) {
return;
}
super.sectionInset = sectionInset;
[self invalidateLayout];
}
-(void) setItemSize:(CGSize)itemSize {
if (CGSizeEqualToSize(super.itemSize, itemSize)) {
return;
}
super.itemSize = itemSize;
[self invalidateLayout];
}
- (CGSize)collectionViewContentSize
{
CGFloat height = [super collectionViewContentSize].height;
// Always returns a contentSize larger then frame so it can scroll and UIRefreshControl will work
if (height < self.collectionView.bounds.size.height) {
height = …Run Code Online (Sandbox Code Playgroud) 正如在iPhone Mail应用程序中所做的那样,我希望在从右到左滑动一个可编辑的表格单元时出现"删除"按钮,以便在它被解除时进行动画处理(通过点击其上的"删除"按钮以外的其他方式UITableViewCell).相反,我的删除按钮会在解除时立即消失.
要在第一个位置刷一个表格单元格时调用"删除"按钮,我已添加(对于该类UITableViewDataSource和UITableViewDelegate该UITableView问题的类):
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//add code here for when you hit delete
}
}
Run Code Online (Sandbox Code Playgroud)
我可以添加一些东西来处理删除按钮的动画吗?谢谢!
我有很多UIButtons内UIScrollView.那些UIButtons人在他们身上附有行动Touch Down Repeat.我的问题是当我触摸按钮然后滚动时我的滚动视图不滚动,但如果我触摸按钮外它可以正常工作.
即使按下按钮,如何允许滚动视图滚动?
UICollectionViewCell当用户点击一个单元格时,我想开始一些动画.我的想法是选择相应的单元格didSelectItemAtIndexPath并触发动画.但是,这不起作用:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
// animate the cell user tapped on
ProductCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ProductReuseID" forIndexPath:indexPath];
[UIView animateWithDuration:5.0
delay:0
options:(UIViewAnimationOptionAllowUserInteraction)
animations:^{
NSLog(@"animation start");
[cell.layer setBackgroundColor:[UIColor colorWithRed: 180.0/255.0 green: 238.0/255.0 blue:180.0/255.0 alpha: 1.0].CGColor];
}
completion:^(BOOL finished){
NSLog(@"animation end");
[cell.layer setBackgroundColor:[UIColor whiteColor].CGColor];
}
];
}
Run Code Online (Sandbox Code Playgroud)
实际上,动画同时开始和结束(尽管animateWithDuration设置为5).下一次尝试是跳过动画并简单地设置一个不同的边框样式:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
// animate the cell user tapped on
ProductCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ProductReuseID" forIndexPath:indexPath];
[cell.layer setBorderWidth:5.0f];
}
Run Code Online (Sandbox Code Playgroud)
但是,这并没有改变任何东西(可能是因为我必须手动重绘单元格?).
你有任何想法如何在用户点击它时动画UICollectionViewCell吗?
亲切的问候,基督徒
如何判断一个UISwitch内部UITableViewCell是否被轻敲?
我UISwitch是在单元格内设置的(通用单元格),如下所示:
UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
[cell addSubview:mySwitch];
cell.accessoryView = mySwitch;
Run Code Online (Sandbox Code Playgroud)
我试图检测这样的水龙头(但它不起作用):
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
NSUserDefaults *prefs;
if(indexPath.section == 1){
switch(indexPath.row)
{
case 0:
NSLog(@"Tapped Login Switch");
break;
default:
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
Dave DeLong建议我为每个交换机设置一个动作作为解决方案.所以我做了以下设置开关:
UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
[mySwitch addTarget:self action:@selector(switchToggled2:) forControlEvents: UIControlEventTouchUpInside];
if(at_songs){
[mySwitch setOn:YES animated:NO];
}
[cell addSubview:mySwitch];
cell.accessoryView = mySwitch;
Run Code Online (Sandbox Code Playgroud)
以下是知道它被点击的时间:
-(IBAction)switchToggled1:(id)sender {
NSUserDefaults *prefs;
NSLog(@"Tapped Login Switch");
prefs = …Run Code Online (Sandbox Code Playgroud) 我正在使用a UICollectionView显示菜单,并且以非常奇怪的方式选择项目.
这是填充它们的静态数据:
self.menuItems = @[@{@"text" : @"First", @"image" : @"180-stickynote.png"},
@{@"text" : @"Second", @"image" : @"180-stickynote.png"},
@{@"text" : @"Third", @"image" : @"180-stickynote.png"},
@{@"text" : @"Fourth", @"image" : @"180-stickynote.png"},
@{@"text" : @"Fifth", @"image" : @"180-stickynote.png"},
@{@"text" : @"Sixth", @"image" : @"180-stickynote.png"}];
Run Code Online (Sandbox Code Playgroud)
和单元格提供程序,其中自定义子类只是附加到原型单元格并具有a UILabel和a UIImageView:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CUMenuCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MenuCell" forIndexPath:indexPath];
NSDictionary *cellInfo = [self.menuItems objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:[cellInfo valueForKey:@"image"]];
cell.label.text = [cellInfo valueForKey:@"text"];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
这是do选择行方法,记录标题和项目的行(它们都在第0部分):
- (void)collectionView:(UICollectionView …Run Code Online (Sandbox Code Playgroud) 我用paragraphStyle.hyphenationFactor = 1,但它只适用于英文文本.如何UITextView使用非英语文本启用连字符或将语言环境设置为UITextView?
我有水平UIScrollView,从水平延伸UIScrollView,我UIButtons水平添加.我只能滚动按钮区域,但如果我想滚动任何按钮是火灾UIControlEventTouchUpInside事件.我不想要这个.我想火UIControlEventTouchUpInside行动,如果我点击我要滚动,如果我滚动.
那么如何将滚动事件传递UIButton给UIScrollView?
我知道如何实现touchesBegan的UIImageView
是有可能实现UITouchDown的UIImageView?(我知道我可以使用touchesBegan,而不是UITouchDown,但我想实现UITouchDown)
iphone ×6
ios ×4
objective-c ×4
xcode ×3
uibutton ×2
uiscrollview ×2
uitableview ×2
animation ×1
cocoa-touch ×1
hyphenation ×1
ios4 ×1
ios6 ×1
scroll ×1
uiimageview ×1
uistoryboard ×1
uiswitch ×1
uitextview ×1
viewdidload ×1