我有一个在iOS6.1上运行良好的应用程序.今天我意识到我应该尝试使这兼容iOS5.我尝试在iOS 5模拟器上运行它,并在我的dequeCell方法调用上抛出一个异常.我无法弄清楚为什么它在iOS6上运行得非常好.还有其他人遇到过这个问题吗?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = //throws exception here
[tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
cell.accessoryView = nil;
cell.backgroundColor = [UIColor colorWithRed:.97
green:.97
blue:.97
alpha:1];
cell.textLabel.textColor = [UIColor blackColor];
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
...
return cell;
}
-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: unrecognized
selector sent to instance 0x8a3a000 -*** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[UITableView
dequeueReusableCellWithIdentifier:forIndexPath:]: unrecognized selector
sent to instance 0x8a3a000'
Run Code Online (Sandbox Code Playgroud) 有些事我想我只是不了解HTML css.当我使用这段代码时:
<!DOCTYPE html>
<html>
<head>
<title>STC </title>
<link href="bootstrap.css" rel="stylesheet">
<script src="bootstrap.js"></script>
<style type="text/css">
...
.loginHeader{
float: right;
padding: 5px;
}
.navLinks{
float: left;
padding: 5px;
}
</style>
</head>
<body>
<div class="topBar">
<div class="navLinks">
<a href=""> Home</a> | <a href=""> About</a> | <a href=""> Suggestions</a> | <a href=""> Terms & Conditions</a>
</div>
<div class="loginheader">
croberts | <a href="/myContracts/">My Contracts</a> | <a href='?logout'>Logout </a>
</div>
</div>
...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的浮动权利不符合我的要求.但是,如果在我的文件的最开始,在doctype声明之前,我添加<style></style>然后它完美地工作.那么为什么这样的东西对那种特定的风格有什么影响呢?其他一切看起来应该是这样的,这只是浮动权问题.
我无法弄清楚这一点。我不断收到“模块”对象在事务对象上没有属性“原子”。不知道为什么突然就破了。我不记得了,但我可能已经更新了我的 django 服务器版本。
from django.db import transaction
@receiver(post_save, sender=User)
def saveUserAndInfo(sender, instance, **kwargs):
user = instance
try:
with transaction.atomic():
user.user_info.save()
except UserInfo.DoesNotExist:
info = UserInfo()
info.user = user
info.save()
Run Code Online (Sandbox Code Playgroud)
追溯:
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "/home2/univetg1/lunchbox/userinfo/views.py" in facebookLogin
190. login(request, user)
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in login
95. user_logged_in.send(sender=user.__class__, request=request, user=user)
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/dispatch/dispatcher.py" in send
170. response = receiver(signal=self, sender=sender, **named)
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/contrib/auth/models.py" in update_last_login
31. user.save(update_fields=['last_login'])
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/models/base.py" in save
546. force_update=force_update, update_fields=update_fields)
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/models/base.py" …Run Code Online (Sandbox Code Playgroud) 我知道我可以用此获取页面上第一张图片的src url
var images = document.getElementsByTagName('img');
var image = images[0]; //get first img
var src = image.getAttribute('src');
Run Code Online (Sandbox Code Playgroud)
但是当src url为:
//domain.com/img/icon.png
Run Code Online (Sandbox Code Playgroud)
我可以通过添加以下行来解决此问题:
if (src.substring(0,2) == '//') src = 'http:'+src;
Run Code Online (Sandbox Code Playgroud)
但是后来我遇到了更多问题。就像网址是什么一样:
'/img/icon.png'
Run Code Online (Sandbox Code Playgroud)
要么
'../img/icon.png'
Run Code Online (Sandbox Code Playgroud)
而且我不知道是否还有其他尚未发现的极端情况。有什么方法可以查询src的完整网址吗?