我想在当前视图上以模态方式呈现具有略微透明背景的视图控制器,这样第一个视图在模态视图下稍微可见.
我设置模态视图控制器的alpha值并设置modalPresentationStyle为UIModalPresentationCurrentContext,如另一篇文章中所建议的那样.
结果是视图背景在动画制作时是透明的,但是当视图控制器就位时,它会变为不透明的黑色.它可以恢复透明,同时激活解雇.
如何在活动时让它变得透明?
我已经测试过了iOS 6 and 7.我使用的代码如下:
MyModalViewController *viewController = [[MyModalViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[navController setNavigationBarHidden:YES];
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self.navigationController presentViewController:navController animated:YES completion:NULL];
Run Code Online (Sandbox Code Playgroud) uiviewcontroller uinavigationcontroller modalviewcontroller ios
这是Apple的代码(来自Technical Q&A QA1702),用于从视频缓冲区获取UIImage.不幸的是,返回的图像旋转了90度.如何编辑它以使返回的图像正确定向?
- (UIImage *) imageFromSampleBuffer:(CMSampleBufferRef) sampleBuffer
{
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer, 0);
void *baseAddress = CVPixelBufferGetBaseAddress(imageBuffer);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t height = CVPixelBufferGetHeight(imageBuffer);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(baseAddress, width, height, 8,
bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
CGImageRef quartzImage = CGBitmapContextCreateImage(context);
CVPixelBufferUnlockBaseAddress(imageBuffer,0);
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
UIImage *image = [UIImage imageWithCGImage:quartzImage];
CGImageRelease(quartzImage);
return (image);
}
Run Code Online (Sandbox Code Playgroud) 我想在我的iPhone程序的简单分组表视图中使用固定图像作为背景.不幸的是,无论我做什么,背景总是纯白色.我已经在这个网站上跟随了几个假设的解决方案而其他方面都无济于事.这是表视图控制器类的viewDidLoad方法中的相关代码(注意,为简单起见,此代码使用纯蓝色而不是图像):
self.tableView.opaque = NO;
self.tableView.backgroundColor = [UIColor clearColor];
UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
backgroundView.backgroundColor = [UIColor blueColor];
[self.tableView.window addSubview:backgroundView];
[backgroundView release];
Run Code Online (Sandbox Code Playgroud)
我怀疑我没有将backgroundView视图放在正确的位置.我尝试过sendToBack :,来自ToFront:和其他人,但我总是得到一个白色背景.是否可以在UITableViewController中执行此操作?我必须使用Interface Builder吗?
我正在尝试在Mac OS X 10.7 Lion上安装需要libmad(MPEG音频解码器库)库的程序,但安装libmad.0.15.b会导致此错误:
version.c:1: error: CPU you selected does not support x86-64 instruction set
Run Code Online (Sandbox Code Playgroud)
该库在OS X 10.5上安装得很好.它是64位兼容性问题吗?我找不到有关在Lion上安装的任何具体说明或文档.有什么建议?谢谢.
我正在尝试使用Apple的" BTLE Transfer "示例项目来了解CoreBluetooth编程.如果我使用iOS 6设备作为中心,应用程序运行正常,但如果我使用iOS 7设备作为中心运行相同的应用程序它不起作用.外围设备在两个数据包之后停止发送,并且中心不接收其中任何一个数据包.
唯一的线索就是这个警告,我只有在iOS 7上运行才会得到:
CoreBluetooth[WARNING] <CBCentralManager: 0x15654540> is disabling duplicate filtering, but is using the default queue (main thread) for delegate events
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我需要更改什么才能使这个应用程序与iOS 7兼容?
编辑:当两个设备都是iOS7时没有问题.这只会在iOS7中心与iOS6外围设备通话时中断.
如何将CVPixelBufferRef转换为NSImage或CGImageRef?我需要能够在核心动画层中显示像素缓冲区的内容.
我正在使用NSFetchedResultsController来管理在具有一个部分的表视图中显示已提取的托管对象.该表开始为空,用户可以使用UI向其添加新实体.目前,程序在添加第一个实体时始终有效,并且在添加第二个实体时始终崩溃.在崩溃时有时没有出现错误,有时会出现不同类型的错误(下面包括一些错误).通过日志语句和跟踪,我看到程序在NSFetchResultsController的委托的controllerWillChangeContent(调用[self.tableView beginUpdates];)方法之后崩溃,但在我的代码中的任何其他方法被调用之前.以下是我的代码中的一些相关部分.配置NSFetchedResultsController:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[NSEntityDescription entityForName:@"Beer"
inManagedObjectContext:self.managedObjectContext]];
// Configure request's entity and predicate
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
[sortDescriptor release];
[sortDescriptors release];
NSString *expression = [NSString stringWithFormat:@"brewery.name LIKE \"%@\"", self.brewery.name];
NSPredicate *predicate = [NSPredicate predicateWithFormat:expression];
[fetchRequest setPredicate:predicate];
self.resultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:self.managedObjectContext
sectionNameKeyPath:nil
cacheName:nil];
self.resultsController.delegate = self;
[fetchRequest release];
NSError *error = nil;
BOOL success = [resultsController performFetch:&error];
if (!success) {
NSLog(@"Error fetching request …Run Code Online (Sandbox Code Playgroud) 我创建了最简单的Android项目,以便使用OnKeyListener测试EditText小部件中的内容.问题是onKey方法只针对返回键触发 - 没有其他方法.根据我的下面的代码,什么可能阻止OnKeyListener工作?
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setViewListeners();
}
private void setViewListeners() {
EditText et1 = (EditText)findViewById(R.id.text1);
EditText et2 = (EditText)findViewById(R.id.text2);
et1.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
Log.i("INFO", "keyCode=" + keyCode);
return false;
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
和布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<Spinner
android:id="@+id/spinner1" …Run Code Online (Sandbox Code Playgroud) iphone ×4
ios ×2
macos ×2
osx-lion ×2
android ×1
avfoundation ×1
background ×1
bluetooth ×1
cocoa ×1
cocoa-touch ×1
core-data ×1
ios7 ×1
mpeg ×1
nsimage ×1
quartz-2d ×1
uitableview ×1
unix ×1