我有一个UITableViewController以标准方式设置UISearchDisplayController(在tableView中有搜索栏).我希望搜索栏开始隐藏 - 真正隐藏,而不仅仅是在此解决方案中滚动.然后,当用户按下按钮时,我想呈现搜索UI,并在用户选择搜索中找到的项目之后再次隐藏它(真正隐藏它).
这是几乎可以工作的代码:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.searchDisplayController.searchBar.prompt = @"Add an item";
self.searchDisplayController.searchBar.placeholder = @"Type the item name";
// i do this to trigger the formatting logic below
[self.searchDisplayController setActive:YES animated:NO];
[self.searchDisplayController setActive:NO animated:NO];
// rest of my view will appear
}
- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller {
NSTimeInterval duration = (self.isViewLoaded && self.view.window)? 0.3 : 0.0;
__block CGFloat searchBarHeight = controller.searchBar.frame.size.height;
[UIView animateWithDuration:duration animations:^{
self.tableView.contentOffset = CGPointMake(0, searchBarHeight);
self.tableView.contentInset = UIEdgeInsetsMake(-searchBarHeight, 0, 0, 0); // trouble here, …Run Code Online (Sandbox Code Playgroud) iphone uitableview uisearchbar uisearchdisplaycontroller ios
我看到很多关于iPhone和iOS的问题.我想作为一个群体重新询问(并回答)他们,一般......
我的目标是清除解析对象上的指针列:
var query = new Parse.Query("MyClass");
query.get("myobjectid").then(function(o) {
o.pointerColumn = undefined;
return o.save();
}).then(function() {
var query2 = new Parse.Query("MyClass");
return query2.get("myobjectid");
}).then(function(o) {
alert(o.pointerColumn);
});
Run Code Online (Sandbox Code Playgroud)
警报(和数据浏览器)向我显示列值仍然存在.我是以错误的方式来做这件事的吗?
我很抱歉,这已在其他地方被问过/回答过。我可能不知道找到所需结果的正确术语。
我正在构建一种 Web 应用程序,在一个区域中,用户单击按钮,从按钮 ID 末尾的数字获取变量,然后将其传递给其他函数以用于进一步处理。我遇到的问题是,随后每次单击类似的按钮时,先前单击的变量仍然存储在这些函数中。
JavaScript 不是我的强项,所以我构建了一个小小提琴,以更小的规模演示我的问题。如果您单击小提琴中的“Submit 1”,然后单击 ALERT CUST_NUM,警报框将显示变量的值。但是,如果您使用“提交 1”或“提交 2”重复该过程(然后再次单击“警报”按钮),则不会警报变量的单个实例,而是会依次显示多个警报框。依此类推,如果您单击“提交 1”,然后单击“警报 CUST_NUM”,然后单击“提交 2”,等等,这样它将在一系列窗口中提醒变量链。我希望有人能解释为什么会发生这种情况,因为我预计函数中只存在一个变量实例,每次都会被覆盖。
$(".submit-btn1").click(function() {
var cust_num = parseInt(this.id.replace('test-button-', ''), 10);
testFunction(cust_num);
})
$(".submit-btn2").click(function() {
var cust_num = parseInt(this.id.replace('test-button-', ''), 10);
testFunction(cust_num);
})
function testFunction(cust_num) {
$("#alert-btn").click(function() {
alert(cust_num);
})
}Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="submit-btn1" id="test-button-1">
Submit 1
</button>
<br/>
<button class="submit-btn2" id="test-button-2">
Submit 2
</button>
<br/>
<button id="alert-btn">
ALERT CUST_NUM
</button>Run Code Online (Sandbox Code Playgroud)
我想修剪视频,所以我正在使用UIVideoEditorController,但是当我检查可以编辑文件时,对于所有文件mp4,mov,m4v,它都返回false。所以任何人都可以指导我什么问题。
我试图使用以下代码从iOS上的Xcode中的支持文件文件夹中访问.txt文件:
NSString* filePath = @"filename.txt";
NSLog(@"File path: %@", filePath);
NSString* fileRoot = [[NSBundle mainBundle] pathForResource:filePath ofType:@"txt"];
NSLog(@"File root: %@", fileRoot);
Run Code Online (Sandbox Code Playgroud)
第一个NSLog打印出我希望它打印的内容,但最后一个NSLog总是打印
文件根:(null)
在(尝试)将文件读入内存后从文件中访问文本也简单地给了我一个(null)打印输出.
这个问题的解决方案可能就在我的鼻子底下,我似乎无法找到它.任何帮助非常感谢!提前致谢.
我想创建一个parse.com云功能,根据是否识别凭据,登录或注册用户.我想我正在接受承诺,特别是关于then和error函数的参数.
这个功能有效:
function signUp(params) {
var password = "my app supplies the password";
var user = new Parse.User();
user.set("username", params['email']); // in my app, email==username
user.set("password", password);
user.set("email", params['email']);
return user.signUp(null);
}
Run Code Online (Sandbox Code Playgroud)
像这样调用它会产生一个很好的signUp结果:
app.post('/reg', function(req, res) {
signUp(req.body).then(function(user) {
res.render('myView', { username: Parse.User.current().get('username') });
}, function(user, error){
res.render('myView', { username: 'error' });
});
});
Run Code Online (Sandbox Code Playgroud)
同样,这个以完全相同的方式调用:
function logIn(params) {
var username = params['email'];
var password = "my app supplies the password";
return Parse.User.logIn(username, password);
}
Run Code Online (Sandbox Code Playgroud)
这是问题所在,为什么这个不起作用?以同样的方式打电话......
function logInOrSignUp(params) {
logIn(params).then(function(user) { …Run Code Online (Sandbox Code Playgroud) 当我试图让当前的星期日期出现在日志中时(星期一到星期日),这就像一周从星期日开始.例如:本周是38岁.昨天是9月20日.我的代码确实显示了周一到周日的日期.但是今天(9月21日)我的日志显示了下周的日期(第39周),当时它仍然是第38周.
我的代码:
NSDate *currentDate = [NSDate date];
NSCalendar *myCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *currentComps = [myCalendar components:( NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekOfYearCalendarUnit | NSWeekdayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:currentDate];
int thisWeeksNumber = currentComps.weekOfYear;
NSLog(@"1 %d", thisWeeksNumber);
[currentComps setWeekday:2];
NSDate *firstDayOfTheWeek = [myCalendar dateFromComponents:currentComps];
NSDate *secondDayOfTheWeek = [self dateByAddingDays:1 toDate:firstDayOfTheWeek];
NSDate *thirdDayOfTheWeek = [self dateByAddingDays:2 toDate:firstDayOfTheWeek];
NSDate *fourthDayOfTheWeek = [self dateByAddingDays:3 toDate:firstDayOfTheWeek];
NSDate *fifthDayOfTheWeek = [self dateByAddingDays:4 toDate:firstDayOfTheWeek];
NSDate *sixthDayOfTheWeek = [self dateByAddingDays:5 toDate:firstDayOfTheWeek];
NSDate *seventhDayOfTheWeek = [self dateByAddingDays:6 toDate:firstDayOfTheWeek]; …Run Code Online (Sandbox Code Playgroud) 如何将115900之类的整数转换为时间?我想按时进行算术运算,以便:115900 + 100等于120000,而不是11600.
我像这样建立电影播放器......
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
player.view.frame = myView.bounds;
player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[player prepareToPlay];
[myView addSubview:player.view];
self.mp = player;
Run Code Online (Sandbox Code Playgroud)
该url指向m3u8网络流.它打得很好.然后我要求这样的图像......
NSTimeInterval currentInterval = self.mp.currentPlaybackTime;
UIImage *image = [self.mp thumbnailImageAtTime:currentInterval timeOption:MPMovieTimeOptionExact];
Run Code Online (Sandbox Code Playgroud)
我已经尝试将currentInterval支持一秒钟.我已经尝试了两种时间选项(精确和关键帧),但图像总是为零.知道为什么吗?谢谢.
我需要对我们正在开发的应用程序进行更改,而不是全职iOS开发人员.我正试图为iOS应用程序获得一个类似于pinterest的界面,并且我正在完成这个教程:https://www.raywenderlich.com/107439/uicollectionview-custom-layout-tutorial-pinterest
在他们的自定义UICollectionViewLayout中,他们覆盖layoutAttributesForElementsinRect但我从XCode 8编译器收到错误(尽管运行使用旧版Swift语言版本设置为是).
我得到的错误是: Method does not override any method from its superclass
缩写代码是:
class PinterestLayout: UICollectionViewLayout {
....
override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? {
var layoutAttributes = [UICollectionViewLayoutAttributes]()
// Loop through the cache and look for items in the rect
for attributes in cache {
if CGRectIntersectsRect(attributes.frame, rect ) {
layoutAttributes.append(attributes)
}
}
return layoutAttributes
}
Run Code Online (Sandbox Code Playgroud)
如果我将方法切换为私有它编译但不起作用,如果我删除覆盖,它会给我一个冲突.我想覆盖底层方法,但不知道如何让它工作.
我想返回 _1, _2 而不是 _1, _2, _1 :
let regex = /_[0-9]/g;
let string = 'a_1 b_2 c_1';
let matches = [...string.matchAll(regex)];
let unique = [...new Set(matches)];
alert(unique);Run Code Online (Sandbox Code Playgroud)
不明白为什么它不删除重复项?
ios ×7
iphone ×4
javascript ×4
objective-c ×4
cocoa-touch ×1
date ×1
file-io ×1
function ×1
ipad ×1
jquery ×1
nscalendar ×1
nsdate ×1
nsstring ×1
uisearchbar ×1
uitableview ×1
variables ×1
xcode ×1