我有两个部分UICollectionView.我想UICollectionView仅显示第1节中的节标题.不在第0部分.
于是,我就回nil以viewForSupplementaryElementOfKind:方法section == 0并返回查看的section == 1.
它崩溃并显示以下错误:
Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes]:
Run Code Online (Sandbox Code Playgroud)
这是补充视图的代码.
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionReusableView *sectionHeader = nil;
if (kind == UICollectionElementKindSectionHeader && indexPath.section == 1) {
sectionHeader = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"EventSectionHeader" forIndexPath:indexPath];
sectionHeader.layer.borderWidth = .5f;
sectionHeader.layer.borderColor = [UIColor colorWithRed:221.0 / 255.0 green:223.0 / 255.0 blue:220.0 / 255.0 alpha:1.0].CGColor;
}
return sectionHeader;
}
Run Code Online (Sandbox Code Playgroud)
我发现在viewForSupplementaryElementOfKind:方法崩溃时也会返回nil .其他答案建议删除该方法.
但我想只显示特定部分的节标题.如何只为一个部分实现返回视图?谢谢.任何帮助,将不胜感激.
编辑:
正如@san所说,我已更新代码以隐藏节标题.有用.它隐藏了标题.但我仍然看到节标题处的空白空间.预期结果是如果隐藏了节标题,则应该没有空格. …
我创建了一个没有的项目ARC.我想在我的项目中使用第三方SDK.这SDK带有ARC支持.所以我想添加ARC第三方文件.我可以通过将此标志添加到构建阶段来禁用ARC所有"MYProject"文件-fno-objc-arc.
但我可能会使用大量文件.所以最好只添加ARC特定的SDK.那么如何SDK在XCodeProject中为单个或特定文件添加ARC支持?
对于实例:我想使用网格视图.我正在添加GMGridView我的项目,它带来了ARC支持.
我希望这可能是重复的问题.但没有一个答案对我没有帮助.我想从我的iOS应用程序中打开一个链接.当我按下按钮时,它会打开safari应用程序并且它总是会显示警告"Safari无法打开页面,因为地址无效".这里的链接看起来像https://itunes.apple.com/gb/app/app_name/id(appId).
我不认为这是发布确切的应用程序链接的好地方.所以上面的链接是虚拟链接,看起来像我的.当我尝试打开链接时,为什么总是会发生错误.我在模拟器和iPod中试过.发生相同的错误.如果我在MAC OS中尝试与Safari相同的链接,那么它的工作原理. 这是我用来从我的应用程序用链接打开Safari的代码.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/gb/app/app_name/id(appId)"]];
Run Code Online (Sandbox Code Playgroud)
我来自印度.以上链接包含gb.这个链接只能从英国开放吗?
更新:
我有良好的工作网络.我还尝试了一件事.我在模拟器中打开我的safari应用程序并在谷歌搜索我的应用程序并单击该链接显示相同的错误.那个苹果方面的链接有问题吗?
有没有办法为所有视图设置相同的背景图像?
在所有viewDidLoad:方法中设置相同的背景.这不酷.
我刚刚升级到Xcode 4.3.1和SDK 5.1.我的项目使用storyboard但有一个nib/xib文件.升级后,编译失败:
/* com.apple.ibtool.errors */
/Users/jhn/Udvikling/Projekter/rmtelemedicin/RMTeleMedicin/RMTeleMedicin/MenuViewController.xib: error: Interface Builder is unable to open documents of type iPad XIB.
Recovery Suggestion: Ensure the plugin for the iPad XIB document type, from the corresponding SDK, is installed.
Run Code Online (Sandbox Code Playgroud)
任何人都看到同样的问题?任何帮助将不胜感激.
我在其中创建了一个tabBar并设置了图像,但是在它下方留下了太多的空间tabBarItem.我怎么能删除它?
这是我tabBar现在的显示

我想像这样展示它

显示Tabbar
firstVC = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
secondVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
thirdVC = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
forthVC = [[ForthViewController alloc] initWithNibName:@"ForthViewController" bundle:nil];
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
NSArray *viewControllersArray = [[NSArray alloc] initWithObjects:firstVC,secondVC,thirdVC,forthVC, nil];
self.tabController = [[UITabBarController alloc] init];
[self.tabController setViewControllers:viewControllersArray animated:NO];
[self.window addSubview:self.tabController.view];
//self.tabController.selectedIndex = 1;
self.tabController.delegate = self;
self.window.rootViewController = self.tabController;
[self.window makeKeyAndVisible];
Run Code Online (Sandbox Code Playgroud)
对于tabBar背景图片我使用了这段代码
UIImage* tabBarBackground = [UIImage imageNamed:@"tabbarimg1.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
Run Code Online (Sandbox Code Playgroud)
并设置img项目我已使用此代码
//used to set the …Run Code Online (Sandbox Code Playgroud) 实际上我正在开发一个ARC启用的项目.我知道使用alloc并init正在拍摄ownership物体.我知道,如果我创建一个像这样的字符串
NSString *myString = [[NSString alloc]initWithFormat:@"Something"];
Run Code Online (Sandbox Code Playgroud)
然后我需要release的myString自己.如果我使用ARC,该怎么办?我无法释放自己.它会造成泄漏吗?或者我应该不创建这样的对象?
我也可以像下面的代码一样创建一个字符串.
NSString *myString = [NSString stringWithFormat:@"Something"];
Run Code Online (Sandbox Code Playgroud)
但是我需要使用哪种类型的ARC启用项目?如果我使用第一种类型会发生什么?
我正在使用Core Data模型和UITableViewController表视图.我的模型似乎工作得很好,但是当我向模型添加实体时,我的表视图没有更新.我相信我的模型正在工作的原因是因为当我添加一个实体时,在运行时没有任何内容显示在视图中,但是如果我剪切任务然后启动它,那么我之前创建的实体突然显示在表视图中.
这是我的表视图控制器 - AudioTableViewController.h
#import <UIKit/UIKit.h>
#import "Bank.h"
#import "Player.h"
@class Player;
@interface AudioTableViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
Player *myMainMan;
}
-(void)addAudioEntityToArray:(AudioFile *)event;
-(NSMutableArray *)recordingsArray;
@end
Run Code Online (Sandbox Code Playgroud)
AudioTableViewController.m(实现文件)
#import "AudioTableViewController.h"
@implementation AudioTableViewController
-(void)addAudioEntityToArray:(AudioFile *)event {
NSIndexPath *indexPath;
if(event.type) {
[[MusikerViewController recordingsArray] addObject:event];//self?
indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
}else {
[[MusikerViewController downloadsArray] addObject:event];
indexPath = [NSIndexPath indexPathForRow:0 inSection:1];
}
[[self tableView] setEditing:YES animated:NO];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationNone];
}
- (void)viewDidLoad {
[[self tableView] reloadData];
[super viewDidLoad];
self.title = @"Audio Files";//put …Run Code Online (Sandbox Code Playgroud) 我想用三个手指制作一个自定义手势识别器.这与unpinch手势识别器类似.
我只需要了解如何识别它.
我的手势需要识别三个方向的三个手指.例如:



我希望图像有意义.我需要使其灵活适应任何三个相反的方向.提前致谢.任何帮助,将不胜感激.
我知道子类方法,我已经用单指半圆形,全圆形创建了自定义手势.我需要一个关于如何处理它的编码想法.
我一直在尝试为图像视图实现视差效果.视差效果的代码很简单,它只在我添加时才UIImage有效UIImageView.我有一个模式图像,需要在两侧平铺自己.
所以我不得不使用patternWithImage方法UIColor.当我进行视差工作时,但是self.view当我倾斜设备时,我可以看到边缘的背景颜色.
这是一个代码:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.backgroundImageView.contentMode = UIViewContentModeCenter;
self.backgroundImageView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"connect"]];
[self addParallaxEffectToView:self.backgroundImageView];
}
- (void)addParallaxEffectToView:(UIView *)view
{
// Set vertical effect
UIInterpolatingMotionEffect *verticalMotionEffect =
[[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.y"
type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
verticalMotionEffect.minimumRelativeValue = @(-50);
verticalMotionEffect.maximumRelativeValue = @(50);
// Set horizontal effect
UIInterpolatingMotionEffect *horizontalMotionEffect =
[[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.x"
type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
horizontalMotionEffect.minimumRelativeValue = @(-50);
horizontalMotionEffect.maximumRelativeValue = @(50);
// Create group to …Run Code Online (Sandbox Code Playgroud) ios ×10
iphone ×5
objective-c ×5
ios7 ×2
alloc ×1
core-data ×1
init ×1
ipad ×1
itunes-store ×1
openurl ×1
safari ×1
swift ×1
tabbar ×1
uicolor ×1
uiimageview ×1
uitabbaritem ×1
uitableview ×1
view ×1
xcode ×1