Post not yet marked as solved
I wanna add a score when the character contacts with the 'coins' and game over when it contacts with the 'enemies'. But it doesn't work. I compiled the ...Category and <SKPhysicsContactDelegate> code in GameScene.h and these:- (instancetype)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
self.character = [SKSpriteNode spriteNodeWithImageNamed:@"character"];
self.character.position = CGPointMake(100, 100);
[self addChild:self.character];
self.physicsWorld.gravity = CGVectorMake(0,0);
self.physicsWorld.contactDelegate = self;
}
return self;
}in .m above didMoveToView method. Can I use initWithSize in Xcode 8? And I do use these code in .m:character.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:character.size]; //1
character.physicsBody.dynamic = YES; //2
character.physicsBody.categoryBitMask = characterCategory; //3
character.physicsBody.contactTestBitMask = coinCategory | enemiesCategory;//4
character.physicsBody.collisionBitMask = 0; // 5I use them in "setPhysicsBody:(SKPhysicsBody *)physicsBody" method. And of couse I compiled the didBeginContact method. Did I miss anything? Please help me. Thank you very much.
Post not yet marked as solved
I am building an iOS app with Google sign-in Facebook sign-in, comment/like system, todo lists, and simple chat system with Swift and Firebase. I am doing open source programming. How much time do I actually need? I used almost 9 months for doing it and haven't finish because of debugging and the storyboard is too slow. Do you all think I took a lot time? Why I take so much time? How can I improve?Please help me, Thanks.
Post not yet marked as solved
I lost all the files in my Xcode project after running git stash. Only ViewController and Main.storyboard left in the project which is empty. I tried all the solutions including git add ., git stash - u, git - save on the net but no solutions. Can anyone help me, please? Any solutions is very appreciated
Post not yet marked as solved
1. I moved the my project from the Mac screen into All My Files, Finder. I can't find anything in All My Files. But I found the project in Documents(previously in Desktop).2. I opened the project, I found out that some file names are in red but others are in black. I tried moving the project from Documents to Desktop. Still the same. I clicked on the red name, and select "Show File Inspector". I followed the path but can't find the files3. Other info, I found out that the path of the files which lost are in Documents while the path of the files which don't lost are in Desktop.Is thare anyway to fix it? I have no idea how to fix it. Anyone please lend me a hand. Thanks.
Post not yet marked as solved
I am using Firebase. I store data in it and retreive in table view controller. But when I added a data, it is at the bottom, I want it to b on the top. Can anyone please tell me whih code I need? Thank you very much.
Post not yet marked as solved
I added search bar to a table view controller programmatically. I use Firebase. But there is no cell since I added search bar. Please see the code:var soemArray = [SomeFile]()
var filteredArray = [SomeFile]()
var shouldShowSearchResults = false
var searchController: UISearchController!
var customSearchController: CustomSearchController!
override func viewDidLoad() {
super.viewDidLoad()
configureCustomSearchController()
}
func getData(){
dataBaseRef.child("text").observe(.value, with: { (snapshot) in
var results = [SomeFile]()
for user in snapshot.children {
let user = SomeFile(snapshot: user as! DataSnapshot)
if user.name != user.url {
results.append(user)
}
}
someArray = results.sorted(by: { (u1, u2) -> Bool in
u1.name < u2.name
})
self.tutsArray = results.sorted(by: { (u1, u2) -> Bool in
u1.url! < u2.url!
})
self.tableView.reloadData()
}) { (error) in
print(error.localizedDescription)
}
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
/
if shouldShowSearchResults {
return filteredArray.count
} else {
return tutsArray.count
}
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "someCell", for: indexPath) as! ArtTutsTableViewCell
cell.name.text = someArray[indexPath.row].tutName
/
if shouldShowSearchResults {
cell.name.text = filteredArray[indexPath.row].name
} else {
cell.name.text = someArray[indexPath.row].name
}
return cell
}
func configureSearchController() {
/
searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self as? UISearchResultsUpdating
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search here..."
searchController.searchBar.delegate = self as? UISearchBarDelegate
searchController.searchBar.sizeToFit()
tableView.tableHeaderView = searchController.searchBar
}
configureCustomSearchController() {
customSearchController = CustomSearchController(searchResultsController: self, searchBarFrame: CGRect(x:0.0, y:0.0, width: tableView.frame.size.width, height:50.0), searchBarFont: UIFont(name: "Futura", size: 16.0)!, searchBarTextColor: UIColor.orange, searchBarTintColor: UIColor.black)
/
tableView.tableHeaderView = customSearchController.customSearchBar
func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
shouldShowSearchResults = true
tableView.reloadData()
}
func searchBarCancelButtonClicked(searchBar: UISearchBar) {
shouldShowSearchResults = false
tableView.reloadData()
}
func searchBarSearchButtonClicked(searchBar: UISearchBar) {
if !shouldShowSearchResults {
shouldShowSearchResults = true
tableView.reloadData()
}
searchController.searchBar.resignFirstResponder()
}
func updateSearchResultsForSearchController(searchController: UISearchController) {
guard let searchString = searchController.searchBar.text else {
return
}
/
self.filteredArray = self.tutsArray.filter({ (tutArray: Tutorials) -> Bool in
let text: NSString = tutArray.tutName
as! NSString
return (text.range(of: searchString, options: NSString.CompareOptions.caseInsensitive).location) != NSNotFound
})
self.tableView.reloadData()
}
func didStartSearching() {
shouldShowSearchResults = true
tableView.reloadData()
}
func didTapOnSearchButton() {
if !shouldShowSearchResults {
shouldShowSearchResults = true
tableView.reloadData()
}
}
func didTapOnCancelButton() {
shouldShowSearchResults = false
tableView.reloadData()
}
func didChangeSearchText(searchText: String) {
self.filteredArray = self.tutsArray.filter({ (tutArray: Tutorials) -> Bool in
let text: NSString = tutArray.tutName as NSString
return (text.range(of: searchText, options: NSString.CompareOptions.caseInsensitive).location) != NSNotFound
})
tableView.reloadData()
}
Post not yet marked as solved
cell.imageView!.image = UIImage(data: data)
cell.imageView?.layer.borderWidth=1.0
cell.imageView?.layer.masksToBounds = true
cell.imageView?.layer.borderColor = UIColor.white.cgColor
cell.imageView?.layer.cornerRadius = (cell.imageView?.frame.size.height)!/2
cell.imageView?.clipsToBounds = trueI added this code to make the image in the cell round. But it is not round. Can anyone tell me why? And help me? Thanks
Post not yet marked as solved
I have Google, Facebook and email sign in. I have made a user profile which shows the users' usernames, countries, full names, biographies and images. The email sign in is successful, I can store all these users' infos in the create account page to Firebase Database. But for Google and Facebook, I can only store some of the infos. I am now searching from your advices. How can I show the User Profile? If I don't show the User Profile for the Google and Facebook users, will it affect their experiences? I am thinking of putting no info in the biographies, countries etc in User Profile, and ask them to create one and I will save those info to the database. The next time, when they come in, they will lose those datas, right? Wish to get your great advices. Thanks
Post not yet marked as solved
My app crash with Admob GADRequest. I tried reinstall Admob, check the app ID and ad unit ID but no help. When I deleted this linebannerView.load(GADRequest)The app not crash anymore but I can't show ad. It crash on this lineclass AppDelegate: UIResponder, UIApplicationDelegate{banneeView.adUnitId= "xxxxx"
bannerView.delegate = self
bannerView.rootViewController = self
let requestAd: GADRequest = GADRequest()
requestAd.testDevices = [kGADSimulatorID]
bannerView.load(requestAd)
Post not yet marked as solved
My app crash with Admob GADRequest. I tried reinstall Admob, check the app ID and ad unit ID but no help. When I deleted this linebannerView.load(GADRequest)The app not crash anymore but I can't show ad. It crash on this lineclass AppDelegate: UIResponder, UIApplicationDelegate{Terminating app due to uncaught exception: ""NSInvalidArgumentExceptionThe code to show ad:bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716"/
bannerView.delegate = self
bannerView.rootViewController = self
let requestAd: GADRequest = GADRequest()
requestAd.testDevices = [kGADSimulatorID]
bannerView.load(requestAd)
Post not yet marked as solved
This is my code:var art: Int = 0
@IBAction func art(_ sender: Any) {
art += 1
tutText = "artTut"
if art == 1{
print(art)
let storyBoard: UIStoryboard = UIStoryboard(name: "Art", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "UITabBarController") as! NewViewController
self.present(newViewController, animated: true, completion: nil)
}
}The log printed '1'. But when I proceed to NewViewController, the log printed '0' See the code in NewViewController.:let main = PreviousViewController()
print(main.art)Do you have solution so that it printed '1' in NewViewController
Post not yet marked as solved
I cannot select button and text field in a table view cell. I don't know why. Anyone please help me?
Post not yet marked as solved
I lost my podfile and cannot 'pod update'. I think it's the cause of why I got 'This app couldn't be installed' in Simulator. How do you think? Wiil 'sudo gem install cocoapods' cause anything to my project? Do anyone has other solutions? Please help. Thanks.
Post not yet marked as solved
My app ran successfully but I got 'This app could not be installed'. I tried the solutions on the internet but no help. Then I realize I lost my Podfile and cannot run 'pod update' in Terminal. Do you think the missing podfile is the cause of the app cannot being installed to Simulator? How to fix the missing podfile? I am thinking of running 'sudo gem install cocoapods' to install the podfile. But will it cause anything to my project. I will be appreciated if someone can give me the solutions. Thanks.