我有以下UIPanGestureRecognizer设置:
- (void)pan:(UIPanGestureRecognizer *)gesture {
if ((gesture.state == UIGestureRecognizerStateChanged) ||
(gesture.state == UIGestureRecognizerStateEnded)) {
CGPoint translation = [gesture translationInView:self.superview];
gesture.view.center = CGPointMake(gesture.view.center.x + translation.x, gesture.view.center.y + translation.y);
[gesture setTranslation:CGPointZero inView:self.superview];
}
}
Run Code Online (Sandbox Code Playgroud)
我想在视图中平移,在同一视图中将一个地方移动到另一个地方.这样做是在移动视图,我如何修改它来做我想要的?
更新:这是我的方法最终正确平移的方式
- (void)pan:(UIPanGestureRecognizer *)gesture {
if ((gesture.state == UIGestureRecognizerStateChanged) ||
(gesture.state == UIGestureRecognizerStateEnded)) {
CGPoint translation = [gesture translationInView:self];;
self.origin = CGPointMake(self.origin.x + translation.x, self.origin.y + translation.y);
[gesture setTranslation:CGPointZero inView:self];
}
}
Run Code Online (Sandbox Code Playgroud)
origin是我视图中的一个属性,它只标记图形中心的位置.在其setter方法中,setNeedsDisplay只要更改此值,就会更新
我在文本中的URL看起来像这样:
<https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/reportAProblem?p
=22000073760328&o=i>
Run Code Online (Sandbox Code Playgroud)
我使用以下模式尝试删除它们:
re.sub(r'\<http.+?\>', '', plain, re.S)
Run Code Online (Sandbox Code Playgroud)
但它不会全部获得它们,例如,这个不会被删除:
<http://ax.phobos.apple.com.edgesuite.net/email/images_shared/spacer_99999\r\n9.gif>
Run Code Online (Sandbox Code Playgroud) 反正有没有像使用findall那样添加不同发现者的结果?例如:
matches = re.finditer(pattern_1, text) + re.finditer(pattern_2, text)
Run Code Online (Sandbox Code Playgroud)
我有几种不同的模式和结果,我想将它们作为单个块而不是单独进行迭代.
我在java Web服务中有以下代码:
public boolean makeFile(String fileName, String audio)
{
if (makeUserFolder())
{
File file = new File(getUserFolderPath() + fileName + amr);
FileOutputStream fileOutputStream = null;
try
{
file.createNewFile();
fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(Base64.decode(audio));
return true;
}
catch(FileNotFoundException ex)
{
return false;
}
catch(IOException ex)
{
return false;
}
finally{
try {
fileOutputStream.close();
convertFile(fileName);
} catch (IOException ex) {
Logger.getLogger(FileUtils.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
else
return false;
}
public boolean convertFile(String fileName)
{
Process ffmpeg;
String filePath = this.userFolderPath + …Run Code Online (Sandbox Code Playgroud) 我UITableViewController didSelectRowAtIndexPath通过以下方式覆盖了我的方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
PhotoListViewController *photosViewController = [[PhotoListViewController alloc] initWithStyle:UITableViewStylePlain];
NSLog(@"Let's see what we got %d", [[fetchedResultsController fetchedObjects] count]);
Person *person = [fetchedResultsController objectAtIndexPath:indexPath];
photosViewController.person = person;
photosViewController.title = [person.name stringByAppendingString:@"'s Photos"];
[self.navigationController pushViewController:photosViewController animated:YES];
[photosViewController release];
}
Run Code Online (Sandbox Code Playgroud)
每当我试图访问fetchedResultsController我得到崩溃时,我在这里设置它:
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"person = %@", person];
fetchedResultsController = [[FlickrFetcher sharedInstance] fetchedResultsControllerForEntity:@"Photo" withPredicate:predicate];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
我只用我的dealloc方法发布它
exc-bad-access objective-c uitableview didselectrowatindexpath ios
完成错误:
Warning (2): Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/trunk/dafe/cake/basics.php:355) [CORE/cake/libs/controller/controller.php, line 743]
Run Code Online (Sandbox Code Playgroud)
据我尝试重定向,我可以告诉它.我知道它是由空格引起的,但我无法在任何地方找到它,这个错误往往在哪里?
编辑:忘了提,这个问题只发生在我的Mac上,我在Windows上的合作伙伴没有这个问题,重定向适合他.
我有以下带有 JQuery 的 AJAX 函数:
var formData = $('#FonykerEditForm').serialize();
$.ajax ({
type: 'POST',
url: '<?php echo $html->url('/fonykers/edit',true); ?>',
data: formData,
dataType: 'json',
success: function(response) {
message.html(response.msg);
message.fadeIn();
if(!response.ok) {
message.removeClass('success');
message.addClass('error');
} else {
message.removeClass('error');
message.addClass('success');
username = $('#FonykerUsername').val();
email = $('#FonykerEmail').val();
}
$('#save-account-button').removeAttr('disabled');
$('.input-text').removeClass('ok');
$('.input-combo').removeClass('ok');
},
error: function (xhr, ajaxOptions, thrownError){
alert(xhr.statusText);
alert(thrownError);
$('#save-account-button').removeAttr('disabled');
}
});
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是表单中的类型文件字段没有与表单的其余数据一起提交,如何将文件包含在 ajax 请求的数据中?
如果我的类A有一个方法foo()和一个B扩展A和覆盖的类foo().如果我写作A a= new B();而不是写作((A) a).foo()- 这foo将被激活?一方面动态类型B和foo()良好覆盖,对其他手工做这个转换使得是一个动态类型的A?
我有以下类覆盖:
class Numeric
@@currencies = {:dollar => 1, :yen => 0.013, :euro => 1.292, :rupee => 0.019}
def method_missing(method_id)
singular_currency = method_id.to_s.gsub( /s$/, '').to_sym
if @@currencies.has_key?(singular_currency)
self * @@currencies[singular_currency]
else
super
end
end
def in(destination_currency)
destination_curreny = destination_currency.to_s.gsub(/s$/, '').to_sym
if @@currencies.has_key?(destination_currency)
self / @@currencies[destination_currency]
else
super
end
end
end
Run Code Online (Sandbox Code Playgroud)
每当in的参数为复数时,例如:10.dollars.in(:yens)我得到ArgumentError: wrong number of arguments (2 for 1)但不10.dollars.in(:yen)产生错误.知道为什么吗?
ios ×2
java ×2
python ×2
regex ×2
ajax ×1
cakephp ×1
cocoa-touch ×1
command-line ×1
ffmpeg ×1
file ×1
forms ×1
http-headers ×1
javascript ×1
jquery ×1
numeric ×1
objective-c ×1
pan ×1
php ×1
process ×1
redirect ×1
ruby ×1
uitableview ×1
url ×1