我想知道如何简单地掩盖任何类型的UIView的可见区域.到目前为止,我所阅读的所有答案/教程都描述了用图像,渐变或创建圆角来掩盖,这比我以前的方式更先进.
示例:我有一个带有边界(0,0,100,100)的UIView,我想用掩码切掉视图的右半部分.因此我的面具框架将是(0,0,50,100).
知道怎么做这个简单吗?我不想覆盖drawrect方法,因为这应该适用于任何UIView.
我试过这个,但它只是让整个视图看不见.
CGRect mask = CGRectMake(0, 0, 50, 100);
UIView *maskView = [[UIView alloc] initWithFrame:mask];
viewToMask.layer.mask = maskView.layer;
Run Code Online (Sandbox Code Playgroud) 比方说,我已经制作了一个类似于a的自定义容器视图控制器UINavigationController,但它顶部有2个导航栏.
然后,在子视图控制器中我使用autolayout,我当然希望内容从第二个导航栏下面开始.
为了自动实现这一点,我需要将顶部布局指南设置为两个导航栏组合的高度.
我假设我们可以覆盖topLayoutGuide-property,但无论我做什么,topLayoutGuide函数永远不会在我的自定义容器视图控制器或子视图控制器中调用.
所以这意味着它topLayoutGuide基本上是一个毫无价值的财产,仅与Apple自己的容器视图控制器一起工作?
请告诉我,我错了!
我正在开发基于Tab Bar应用程序预设的应用程序.在其中一个选项卡中,我有一个显示大量数据的表格视图,但当我滚动到底部时,表格视图中最后一个单元格的一半被标签栏覆盖.
有人有解决方案吗?
我正在尝试使用iOS 4.1在iPhone上的资源文件夹中播放视频文件.MPMoviePlayerViewController显示视图,但它只会在活动指示器旋转时显示"正在加载电影...".谁知道这个的原因?我尝试过各种适用于iPhone的视频格式,每次都有相同的结果.
电影播放器响应显示和隐藏控件等操作.
我的代码:
-(void) playVideoNamed:(NSString *)videoName
{
// I get the path like this so the user can enter extension in the filename
NSString *path = [NSString stringWithFormat:@"%@/%@",
[[NSBundle mainBundle] resourcePath], videoName];
NSLog(@"Path of video file: %@", path);
RootViewController *rootController = [(DerpAppDelegate *)[[UIApplication sharedApplication] delegate] viewController];
NSURL *url = [NSURL URLWithString:path];
MPMoviePlayerViewController *vc = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
vc.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[rootController presentMoviePlayerViewControllerAnimated:vc];
[vc.moviePlayer prepareToPlay]; // Not sure about this... I've copied this code from various others that claims this …Run Code Online (Sandbox Code Playgroud) iphone video objective-c mpmovieplayercontroller iphone-video
我试图在Xcode 4.3.2(4E2002)中禁用换行,但设置似乎不起作用.我认真地讨厌线条缠绕,这让我非常无益.我之前一直关闭它,但自从最新的XCode更新以来,无论设置如何都启用它.
这是一个Xcode错误吗?
这是我的设置对话框:

我正在编写一个使用GPS数据的iPhone应用程序.我的问题是即使我杀了实际的过程,GPS也永远不会停止更新位置(箭头停留在状态栏上).使其消失的唯一方法是卸载应用程序,或禁止它在系统设置中使用位置.
这就是我创建位置管理器的方式:
// Create the location manager if this object does not
// already have one.
if (nil == locationManager)
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = regionTracker;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
// Set a movement threshold for new events.
locationManager.distanceFilter = 1;
[locationManager startUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)
在我的app委托中,我在applicationWillTerminate:和applicationDidEnterBackground中运行这两行:
[self.viewController.locationManager stopUpdatingLocation];
[self.viewController.locationManager setDelegate:nil];
Run Code Online (Sandbox Code Playgroud)
我没有代表,因为我看到他们这样做的一些例子,但它真的需要吗?
我有一个UITableView显示我在界面构建器中设计的自定义视图单元格.它有很多按钮和标签以及渐变背景,这使得滚动性能变得邋,,每次新单元加载时它都"滞后".我已经阅读了创建Tweetie关于快速滚动的人的指南,并且它说最好手动绘制所有内容.
有没有其他方法可以做到这一点?我想使用我的.xib文件,因为手动绘制所有这些组件是相当繁琐的工作.
这是cellForRowAtIndexPath:方法的实现方式:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ThreadsViewCell";
ThreadViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ThreadViewCell" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[ThreadViewCell class]])
{
cell = (ThreadViewCell *)currentObject;
break;
}
}
}
Run Code Online (Sandbox Code Playgroud) iphone ×4
objective-c ×3
ios ×2
uitableview ×2
autolayout ×1
ios4 ×1
ios7 ×1
iphone-video ×1
mask ×1
performance ×1
uiview ×1
video ×1
word-wrap ×1
xcode ×1