使用navigationItem.titleView在iOS11上查看行为,其中titleView的宽度不是屏幕的整个宽度.
我有一个自定义视图,我将其设置为titleView.在iOS11之前,视图将填充导航栏区域.但iOS 11并没有调整大小来填充屏幕的宽度.
我在设置titleView之前尝试设置视图的框架,但没有运气.我试图强制titleViews superview布局约束,但没有运气.
附上截图:
iOS10:
iOS11:
还有其他人经历过吗?
uinavigationbar uinavigationcontroller navigationitem ios ios11
我很难在python中获取一些sql以正确浏览MySQLdb.它是pythons字符串格式化,正在杀死我.
我的sql语句使用带有通配符的LIKE关键字.我在Python中尝试了很多不同的东西.问题是,一旦我让其中一个工作,MySQLdb中的一行代码就是字符串格式.
尝试1:
"SELECT tag.userId,count(user.id)as totalRows FROM user INNER JOIN tag ON user.id = tag.userId WHERE user.username LIKE'%% s%'"%(query)
这是不行的.我得到价值错误:
ValueError:索引128处不支持的格式字符'''(0x27)
尝试2:
"SELECT tag.userId,count(user.id)as totalRows FROM user INNER JOIN tag ON user.id = tag.userId WHERE user.username LIKE'\ %% s \%'"%(query)
我从尝试1得到了相同的结果.
尝试3:
like ="LIKE'%"+ str(查询)+"%'"totalq ="SELECT tag.userId,count(user.id)as totalRows FROM user INNER JOIN tag ON user.id = tag.userId WHERE user.username "+喜欢
这正确地创建了totalq变量,但是现在当我去运行查询时,我从MySQLdb获得错误:
文件"build/bdist.macosx-10.6-universal/egg/MySQLdb/cursors.py",第158行,执行查询=查询%db.literal(args)TypeError:格式字符串的参数不够
尝试4:
like ="LIKE'\%"+ str(查询)+"\%'"totalq ="SELECT tag.userId,count(user.id)as totalRows FROM user INNER JOIN tag ON user.id = tag.userId WHERE user …
当我调用最小支持目标的SDK中没有的方法时,有没有办法让Xcode告诉我?
例如,方法[NSURLConnection sendAsynchronousRequest:queue:completionHandler:].此方法适用于iOS5及更高版本.但我的应用程序的最低目标是iOS4.
如果我使用该方法(sendAsync),我希望Xcode告诉我该方法不适用于我试图支持的最小目标.
我已经尝试在预处理器设置中放置__IPHONE_OS_VERSION_MAX_ALLOWED = 40000,但这只会触发一堆无用的Apple SDK错误.(可能是因为我的活动SDK是iOS5.1)
是获得旧SDK的唯一解决方案并将其安装在Xcode中吗?
有没有更简单的解决方案?
我正在将应用程序转换到相当流畅的iOS 7,有一点我无法弄清楚.
我有一个带有几个按钮的视图控制器,我用UIPopoverController显示.
在我看来,像弹出控制器正在做一些事情来剪切它的视图控制器的内容被舍入.
iOS6(我想要这个):
iOS7(改变了一些东西):
我正在使用这里描述的自定义popover控制器后台类http://blog.teamtreehouse.com/customizing-the-design-of-uipopovercontroller
这是我的背景类http://pastebin.com/fuNjBqwU的特定版本
有没有人知道要改变什么才能让它回到我的iOS 6外观?
当您将视图滚动到顶部或底部时,如何禁用显示的小黄色渐变.当您到达可滚动区域的边界时,黄色渐变进入,如果您尝试继续滚动,渐变开始显示越来越多.
我尝试过使用"setVerticalFadingEdgeEnabled(false)",但这不起作用.
作为参考,这是我设置webview的方式:
isiWebView = (WebView)_view.findViewById(R.id.isiWebView);
isiWebView.getSettings().setJavaScriptEnabled(true);
isiWebView.loadUrl("file:///android_asset/isi.html");
isiWebView.setBackgroundColor(0);
isiWebView.addJavascriptInterface(this,"JSInterface");
isiWebView.setVerticalFadingEdgeEnabled(false);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢!
我让Django用fastcgi_pass在Nginx后面跑.我在像"/ django/sample"这样的子路径上运行Django.
location /django/sample {
include fastcgi_params;
fastcgi_pass 127.0.0.1:8025;
}
Run Code Online (Sandbox Code Playgroud)
我在django设置模块中使用FORCE_SCRIPT_NAME,它似乎解决了我在子路径上运行时遇到的所有问题.
在settings.py中:
FORCE_SCRIPT_NAME = "/django/sample/"
Run Code Online (Sandbox Code Playgroud)
我去这里用admin登录(并正确获取管理员用户界面):
http://server/django/sample/admin
Run Code Online (Sandbox Code Playgroud)
但是当我提交时,它会重定向到:
http://server/django/sample/django/sample/admin
Run Code Online (Sandbox Code Playgroud)
真正奇怪的是,如果我更改FORCE_SCRIPT_NAME =""登录有效.
但是,管理页面中的所有链接都是/ admin,而不是/ django/sample/admin /
我错过了什么?设置FORCE_SCRIPT_NAME ="/ django/sample /"似乎可以修复除管理员登录之外的所有内容.
有任何想法吗?
更新:
我也尝试在nginx conf中使用fastcgi_split_path_info(并在设置中取出FORCE_SCRIPT_NAME).再次修复除管理员登录重定向之外的所有路径问题.
像这样:
location /django/sample {
fastcgi_split_path_info ^(/django/sample)(.*)$;
include fastcgi_params;
fastcgi_pass 127.0.0.1:8025;
}
Run Code Online (Sandbox Code Playgroud) 有一个大脑放屁,无法弄清楚为什么没有调用NSCollectionView的dataSource方法.
我遇到的NSCollectionView的所有样本都在使用绑定.即使是Apple的"编程指南",与其他大多数通常令人惊叹的编程指南相比,都非常简短.
我有一个沙箱测试设置只是为了测试这个.我正在从dribbble.com加载图片.
这是我的AppDelegate.h:
#import <Cocoa/Cocoa.h>
#import "Dribbble.h"
@interface AppDelegate : NSObject <NSApplicationDelegate,NSCollectionViewDataSource,NSCollectionViewDelegate>
@property IBOutlet NSCollectionView * collectionView;
@end
Run Code Online (Sandbox Code Playgroud)
和AppDelegate.m
#import "AppDelegate.h"
#import "DribbbleCell.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@property Dribbble * dribbble;
@property NSMutableArray * dribbbleShots;
@property NSInteger page;
@property NSInteger maxPage;
@end
@implementation AppDelegate
- (void) applicationDidFinishLaunching:(NSNotification *) aNotification {
self.page = 0;
self.maxPage = 1;
self.dribbbleShots = [NSMutableArray array];
self.dribbble = [[Dribbble alloc] init];
self.dribbble.accessToken = @"XXXX";
self.dribbble.clientSecret = @"XXXX";
self.dribbble.clientId = @"XXXX";
NSNib …
Run Code Online (Sandbox Code Playgroud) 我想要按顺序播放两个视频.我尝试过AVQueuePlayer,但两个剪辑之间有一个巨大的"打嗝".我需要他们不间断地玩.
所以我正在尝试使用AVMutableComposition和AVPlayer,但无法正确使用它.
这是我的代码(忽略内存泄漏,只是在空项目中测试..):
composition = [[AVMutableComposition alloc] init];
NSString * path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp4"];
NSURL * url = [NSURL fileURLWithPath:path];
AVURLAsset * asset = [[AVURLAsset alloc] initWithURL:url options:nil];
NSError * error = NULL;
[composition insertTimeRange:CMTimeRangeMake(CMTimeMake(0,1000),CMTimeMake(4,1000)) ofAsset:asset atTime:CMTimeMake(0,1000) error:&error];
if(error) NSLog(@"error: %@",error);
path = [[NSBundle mainBundle] pathForResource:@"chug1" ofType:@"mp4"];
url = [NSURL fileURLWithPath:path];
asset = [[AVURLAsset alloc] initWithURL:url options:nil];
error = NULL;
[composition insertTimeRange:CMTimeRangeMake(CMTimeMake(0,1000),CMTimeMake(3,1000)) ofAsset:asset atTime:CMTimeMake(4.1,1000) error:&error];
if(error) NSLog(@"error: %@",error);
AVPlayerItem * item = [[AVPlayerItem alloc] initWithAsset:composition];
AVPlayer * player …
Run Code Online (Sandbox Code Playgroud) 我怎样才能让NSURLConnection从不同的线程而不是主线程调用它的委托方法.我正在尝试使用scheduleInRunLoop:forMode:但似乎没有做我想要的.
我必须下载一个大文件,它会频繁地中断主线程,以至于正在发生的一些渲染开始变得不稳定.
NSURLRequest * request = [NSURLRequest requestWithURL:url];
NSURLConnection * connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
NSRunLoop * loop = [NSRunLoop currentRunLoop];
NSLog(@"loop mode: %@",[loop currentMode]);
[connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
[connection start];
Run Code Online (Sandbox Code Playgroud)
我没有看到的另一件事是"模式"只记录了两种模式,所以没有多少真正要测试.
有任何想法吗?
谢谢
最近升级到Xcode 11 / iOS13。在新的视图控制器上工作。UICollectionView调用了我的sizeForItemAtPath委托方法,但是看来集合视图总是根据约束选择自定义大小。但是我不想要它!
我试图将估计大小设置为1x1,只是为了尝试解决此问题。没用 我在所有委托/数据源方法上都断点了,看不到任何异常。
我也遇到了这个问题(在iOS 13上未调用过`systemLayoutSizeFittingSize`),也许我的问题与之有关吗?我可以通过覆盖该链接中的systemFittingSize方法来解决此问题- 但我确实不必这样做。
我发现奇怪的是,任何具有集合视图的现有xib都能按预期工作-唯一的区别似乎是我使用Xcode 11 VS Xcode 10创建了单元格/集合视图。
我还注意到Xcode11中的UICollectionViewCell元素包含“内容视图”-但Xcode 10 xib没有内容视图。
还有其他人遇到吗?