Rectangle 27 66

Debug toolbar wants the ip address in request.META['REMOTE_ADDR'] to be set in the INTERNAL_IPS setting. Throw in a print statement in one of your views like such:

print("IP Address for debug-toolbar: " + request.META['REMOTE_ADDR'])

And then load that page. Make sure that IP is in your INTERNAL_IPS setting in settings.py.

Normally I'd think you would be able to determine the address easily by looking at your computer's ip address, but in my case I'm running the server in a Virtual Box with port forwarding...and who knows what happened. Despite not seeing it anywhere in ifconfig on the VB or my own OS, the IP that showed up in the REMOTE_ADDR key was what did the trick of activating the toolbar.

INTERNAL_IPS

From my guest machine in VirtualBox, my host machine is seen as 10.0.0.2, if it can help someone. :)

In docker my REMOTE_ADDR was not what I would have assumed.

python - django-debug-toolbar not showing up - Stack Overflow

python django django-debug-toolbar
Rectangle 27 23

There is a plunker showing how we can configure the views dynamically. The updated version of the .run() would be like this:

app.run(['$q', '$rootScope', '$state', '$http',
  function ($q, $rootScope, $state, $http) 
  {
    $http.get("myJson.json")
    .success(function(data)
    {
      angular.forEach(data, function (value, key) 
      { 
          var state = {
            "url": value.url,
            "parent" : value.parent,
            "abstract": value.abstract,
            "views": {}
          };

          // here we configure the views
          angular.forEach(value.views, function (view) 
          {
            state.views[view.name] = {
              templateUrl : view.templateUrl,
            };
          });

          $stateProviderRef.state(value.name, state);
      });
      $state.go("home");    
    });
}]);

Check that all in action here

Thank you so much, why do you have a non-named ui-view as well as the other 4 named ui-views?

Great if that helped ;) yeah... that was... for testing ;) sorry, it should not be there! great spot sir ;)

Hey, this is a nice solution but what if i want to go to the current state, not $state.go("home"); I want ui-router to parse and find out which one the current state is and go there. Is there a way to do that?

Any time you do have access to $state.current. There should be exatly current state. You can use this like $state.current.name

Nope, the current state is Object {name: "", url: "^", views: null, abstract: true}. I don't know in which state i'm in yet because the router was just configured after the $http request...

AngularJS - UI-router - How to configure dynamic views - Stack Overflo...

angularjs angular-ui-router
Rectangle 27 44

It's because you're hiding some of your views sometimes, and you never show them again. Example:

if (!(datapark.get(position).bio.equals(""))){ 
          holder.bio.setVisibility(View.VISIBLE);         
          holder.bio.setText(datapark.get(position).bio);
        }else{
          holder.bio.setVisibility(View.GONE);
        }

Remember that views are recycled, so, unless you show the views the next time you return one, they will never be visible again. Also, remember that holder.bio is the same thing that is returned by the findViewById, so you can do holder.bio.setVisibility(View.GONE) in the else block.

GOd you have saved me from 1 week old mess :D

android - Why do items disappear when I scroll the listView? - Stack O...

android xml listview layout scrollview
Rectangle 27 5

I think your indexTest logic is wrong, it's showing the wrong indexes for the viewControllers. I wouldn't use those methods to keep track of the index as they can be called even when the views aren't actually going to change.

Instead you could replace the selection of view controllers like this:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {

    int vcIndex = [self.viewControllers indexOfObject:viewController];
    if (vcIndex > 0) {
        return [self.viewControllers objectAtIndex:vcIndex-1];
    }
    return nil;
}

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {

    int vcIndex = [self.viewControllers indexOfObject:viewController];
    if (vcIndex < NUM_OF_PAGES-1) {
        return [self.viewControllers objectAtIndex:vcIndex+1];
    }
    return nil;
}

And if you need to keep track of the current index, use the delegate method provided.

- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed {
    if (completed && finished) {
        UIViewController *currentVC = pageViewController.viewControllers[0];
        indexTest = [self.viewControllers indexOfObject:currentVC];
    }
}

Just note that if your using this method, don't call setViewControllers: amimated:YES as this will lose track of the correct position.

Side note: I too have been struggling with UIPageViewController and found it was quicker and easier to write my own version. I think it has too many bugs.

Thank you James P! Works perfect now. I see where I was going wrong now, well understand how my previous code was causing problems. On with the rest of the program now! :-)

ios - UIPageViewController blanking page - Stack Overflow

ios xcode nib uipageviewcontroller
Rectangle 27 5

I think your indexTest logic is wrong, it's showing the wrong indexes for the viewControllers. I wouldn't use those methods to keep track of the index as they can be called even when the views aren't actually going to change.

Instead you could replace the selection of view controllers like this:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {

    int vcIndex = [self.viewControllers indexOfObject:viewController];
    if (vcIndex > 0) {
        return [self.viewControllers objectAtIndex:vcIndex-1];
    }
    return nil;
}

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {

    int vcIndex = [self.viewControllers indexOfObject:viewController];
    if (vcIndex < NUM_OF_PAGES-1) {
        return [self.viewControllers objectAtIndex:vcIndex+1];
    }
    return nil;
}

And if you need to keep track of the current index, use the delegate method provided.

- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed {
    if (completed && finished) {
        UIViewController *currentVC = pageViewController.viewControllers[0];
        indexTest = [self.viewControllers indexOfObject:currentVC];
    }
}

Just note that if your using this method, don't call setViewControllers: amimated:YES as this will lose track of the correct position.

Side note: I too have been struggling with UIPageViewController and found it was quicker and easier to write my own version. I think it has too many bugs.

Thank you James P! Works perfect now. I see where I was going wrong now, well understand how my previous code was causing problems. On with the rest of the program now! :-)

ios - UIPageViewController blanking page - Stack Overflow

ios xcode nib uipageviewcontroller
Rectangle 27 222

My personal preference for showing/hiding views is to create an IBOutlet with the appropriate width or height constraint.

I then update the constant value to 0 to hide, or whatever the value should be to show.

The big advantage of this technique is that relative constraints will be maintained. For example let's say you have view A and view B with a horizontal gap of x. When view A width constant is set to 0.f then view B will move left to fill that space.

There's no need to add or remove constraints, which is a heavyweight operation. Simply updating the constraint's constant will do the trick.

exactly. As long as - in this example - you position view B to the right of view A using a horizontal gap. I use this technique all the time and it works very well

@MaxMacLeod Just to make sure: if the gap between the two views are x, in order for the view B to start from view A position, we must also change the gap constraint constant to 0, too, right?

@kernix yes if there would need to be a horizontal gap constraint between the two views. constant 0 of course means no gap. So hiding view A by setting it's width to 0 would move view B left to be flush with the container. Btw thanks for the up votes!

@MaxMacLeod Thanks for your answer. I tried doing this with a UIView that contains other views, but that view's subviews aren't hidden when I set its height constraint to 0. Is this solution supposed to work with views containing subviews? Thanks!

Would also appreciate a solution that works for a UIView containing other views...

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

ios - AutoLayout with hidden UIViews? - Stack Overflow

ios objective-c autolayout
Rectangle 27 6

I was struggling with this today, and no matter what I did, my views were always showing up as 320x480, even when running on the retina 4" simulator. Even [UIScreen mainScreen].bounds was returning 320x480!

I found that adding the Default-568h@2x.png launch image was the key to getting iOS to recognize my app as 'retina 4" ready'. Once I did that, I found had to do nothing else to get nibs to automatically size without the black bars. No need to have two separate xibs, change settings in Interface Builder, overriding loadView, etc.

unbelievable, exactly the same case for me. i had a warning in xcode about the missing Default-568h@2x.png file and xcode even offered to add it for me. after that all was golden.

xcode - How to make xib compatible with both iphone 5 and iphone 4 dev...

iphone xcode interface-builder
Rectangle 27 2

From my understanding of your Views stack in your viewController, you simply need to move the transparent view to the front of the stack (it is currently at the back of your superView).

You can do this by calling.

And in the storyboard just set the view to the correct values

If you want to hide the view just call

[self.view bringSubViewToFront:<your tableView>];

To create a transparent view on top of you UITableView, you need to add a UIView in the storyBoard that is a subView of your viewController main view(then set all the attributes you want in the attributes inspector). Your tableView need to be also a subView of your viewController main view.

*make sure that the transparent view is front of the tableView in your storyBoard

In order to handle the gestures (because the transparent view is "blocking" the gestures from the tableView read this post Link)

tried it but not working

if I add [self.view bringSubViewToFront:<your transparent view>];then cellForRowAtIndexPath not getting called

can you add your code? from what you described it's not logical to happen

when do you want your transparent view to be on top? from the beginning?

ios - display list of images in UITableview with trasparent view - Sta...

ios objective-c iphone uitableview uiview
Rectangle 27 17

Simple: adapt your view models to match your views requirement (which is to show a list of checkboxes for some roles), use editor templates and avoid writing loops in your views.

public class RegisterModel
{
    public List<RoleModel> Roles { get; set; }
}

public class RoleModel
{
    public string RoleName { get; set; }
    public bool Selected { get; set; }
}
public class HomeController : Controller
{
    public ActionResult Index()
    {
        var model = new RegisterModel
        {
            Roles = new[]
            {
                new RoleModel { RoleName = "administrator" },
                new RoleModel { RoleName = "developer" },
                new RoleModel { RoleName = "janitor :-)" },
            }.ToList()
        };
        return View(model);
    }

    [HttpPost]
    public ActionResult Index(RegisterModel model)
    {
        // at this stage the model will contain all the 
        // information you need
        return View(model);
    }
}
~/Views/Home/Index.cshtml
@model RegisterModel

@using (Html.BeginForm())
{
    @Html.EditorFor(x => x.Roles)
    <button type="submit">OK</button>
}
~/Views/Home/EditorTemplates/RoleModel.cshtml
@model RoleModel

<div>
    @Html.HiddenFor(x => x.RoleName)
    @Html.CheckBoxFor(x => x.Selected)
    @Html.LabelFor(x => x.Selected, Model.RoleName)
</div>

Great job! Didn't know the EditorFor would handle Lists so nicely.

asp.net mvc - MVC3 How To Bind Multiple Checkboxes to 1 Property in Vi...

asp.net-mvc asp.net-mvc-3 checkbox viewmodel model-binding
Rectangle 27 17

Simple: adapt your view models to match your views requirement (which is to show a list of checkboxes for some roles), use editor templates and avoid writing loops in your views.

public class RegisterModel
{
    public List<RoleModel> Roles { get; set; }
}

public class RoleModel
{
    public string RoleName { get; set; }
    public bool Selected { get; set; }
}
public class HomeController : Controller
{
    public ActionResult Index()
    {
        var model = new RegisterModel
        {
            Roles = new[]
            {
                new RoleModel { RoleName = "administrator" },
                new RoleModel { RoleName = "developer" },
                new RoleModel { RoleName = "janitor :-)" },
            }.ToList()
        };
        return View(model);
    }

    [HttpPost]
    public ActionResult Index(RegisterModel model)
    {
        // at this stage the model will contain all the 
        // information you need
        return View(model);
    }
}
~/Views/Home/Index.cshtml
@model RegisterModel

@using (Html.BeginForm())
{
    @Html.EditorFor(x => x.Roles)
    <button type="submit">OK</button>
}
~/Views/Home/EditorTemplates/RoleModel.cshtml
@model RoleModel

<div>
    @Html.HiddenFor(x => x.RoleName)
    @Html.CheckBoxFor(x => x.Selected)
    @Html.LabelFor(x => x.Selected, Model.RoleName)
</div>

Great job! Didn't know the EditorFor would handle Lists so nicely.

asp.net mvc - MVC3 How To Bind Multiple Checkboxes to 1 Property in Vi...

asp.net-mvc asp.net-mvc-3 checkbox viewmodel model-binding
Rectangle 27 14

You should always create separate ViewModels for your views. There should be an abstraction from your Views to your Domain Models. In the demos/tutorials they show it all pretty and easy by simply strongly typing the Views to Domain Models but that's not a good strategy. The views should not be dependent on the business objects.

You should implement David Glenn's proposed solution for your current scenario and also for all other views even if requires mapping the domain model to to another view model class.

If you have lets say a top Menu > TopMenu.aspx And you have multiple partial views inside it > StudentMenu.ascx, ResultMenu.ascx

You will create a View Model for Top Menu > TopMenuViewModel.cs And you will also create view models for partial views > StudentMenuViewModel , ResultMenuViewModel etc.

and your TopMenuViewModel will have both >

class TopMenuViewModel 
{
   //all the stuff required in TopMenu.aspx
   StudentMenuViewModel studentvm;
   ResultMenuViewModel resultvm;
}

and in TopMenu.aspx when rendering the partial you will pass the relevant view model >

Html.RenderPartial('StudentView', Model.studentvm)

Yup mostly but if you are building a large project, you should always be abstracting your domain objects and view models.

Hi thanks for the tip, that's the plan from the start to separate the domain models. But I get confuse on how will I send the model objects from the controller, specially when I divided my page into several partial views. And some partial views depend on certain models. For example in my partial view menu, assuming I have a MenuViewModel. Add the MenuViewModel in a match bigger model CompilationViewModel (menu, students, etc), how will I access that particular view model in a given view? Or much worse access 2 view models in a single view? Thanks.

Hi, thanks for the sample code. It sure is helpful, I just thought I could get away without passing the model from the main view, just access the view model directly from the partial view.

asp.net mvc - Multiple Models in a Single View (C# MVC3) - Stack Overf...

c# asp.net-mvc asp.net-mvc-3
Rectangle 27 14

if you use actionBarSherlock, you can use the com.actionbarsherlock.internal.widget.IcsLinearLayout class in order to support dividers and show them between the views .

<com.actionbarsherlock.internal.widget.IcsLinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:divider="@drawable/divider"
    android:dividerPadding="10dp"
    android:orientation="vertical"
    android:showDividers="beginning|middle|end" >
... children...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <size android:height="2dip" />

    <solid android:color="#FFff0000" />

</shape>

do note that for some reason, the preview in the graphical designer says "android.graphics.bitmap_delegate.nativeRecycle(I)Z" . not sure what it means, but it can be ignored as it works fine on both new versions of android and old ones (tested on android 4.2 and 2.3) .

seems the error is only shown when using API17 for the graphical designer.

Android Drawing Separator/Divider Line in Layout? - Stack Overflow

android layout draw
Rectangle 27 14

if you use actionBarSherlock, you can use the com.actionbarsherlock.internal.widget.IcsLinearLayout class in order to support dividers and show them between the views .

<com.actionbarsherlock.internal.widget.IcsLinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:divider="@drawable/divider"
    android:dividerPadding="10dp"
    android:orientation="vertical"
    android:showDividers="beginning|middle|end" >
... children...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <size android:height="2dip" />

    <solid android:color="#FFff0000" />

</shape>

do note that for some reason, the preview in the graphical designer says "android.graphics.bitmap_delegate.nativeRecycle(I)Z" . not sure what it means, but it can be ignored as it works fine on both new versions of android and old ones (tested on android 4.2 and 2.3) .

seems the error is only shown when using API17 for the graphical designer.

Android Drawing Separator/Divider Line in Layout? - Stack Overflow

android layout draw
Rectangle 27 14

if you use actionBarSherlock, you can use the com.actionbarsherlock.internal.widget.IcsLinearLayout class in order to support dividers and show them between the views .

<com.actionbarsherlock.internal.widget.IcsLinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:divider="@drawable/divider"
    android:dividerPadding="10dp"
    android:orientation="vertical"
    android:showDividers="beginning|middle|end" >
... children...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <size android:height="2dip" />

    <solid android:color="#FFff0000" />

</shape>

do note that for some reason, the preview in the graphical designer says "android.graphics.bitmap_delegate.nativeRecycle(I)Z" . not sure what it means, but it can be ignored as it works fine on both new versions of android and old ones (tested on android 4.2 and 2.3) .

seems the error is only shown when using API17 for the graphical designer.

Android Drawing Separator/Divider Line in Layout? - Stack Overflow

android layout draw
Rectangle 27 14

if you use actionBarSherlock, you can use the com.actionbarsherlock.internal.widget.IcsLinearLayout class in order to support dividers and show them between the views .

<com.actionbarsherlock.internal.widget.IcsLinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:divider="@drawable/divider"
    android:dividerPadding="10dp"
    android:orientation="vertical"
    android:showDividers="beginning|middle|end" >
... children...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <size android:height="2dip" />

    <solid android:color="#FFff0000" />

</shape>

do note that for some reason, the preview in the graphical designer says "android.graphics.bitmap_delegate.nativeRecycle(I)Z" . not sure what it means, but it can be ignored as it works fine on both new versions of android and old ones (tested on android 4.2 and 2.3) .

seems the error is only shown when using API17 for the graphical designer.

Android Drawing Separator/Divider Line in Layout? - Stack Overflow

android layout draw
Rectangle 27 1

First of all if you are showing code for your index action, why is it the view action?

I have a controller and in the index view...

class ModelController < ApplicationController
  def view

  # should be

  def index
app/views/models/index.html.erb
app/views/model/_view.html.erb
models
<%= render "model/view", :@model => Model.first %>

<!-- should be -->

<%= render "models/view", :model => @model %>

And set @model in your controller. You can put Model.first into the view itself, but I think that breaks MVC pattern a little bit.

Finally in the partial, you access the class variable @model defeating the purpose of passing it as a local. You also call .each on it, which is a method for looping through collections, not for individual records. For example you would do @models.each and never @model.each.

<% @model.each do |m| %>
  <div><%= m.name %></div>
<% end %>

<!-- should be something like -->

<%= model.name %>

Long story short, seems to me you're pretty lost, so I would start with a good book about Ruby on Rails before you continue. Here's a free one: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book?version=4.0

Ruby render another controller partial - Stack Overflow

ruby ruby-on-rails-3 views
Rectangle 27 6

The problem is that each image is decoded at the moment the view is prepared for showing. The ListView will recycle your views that means that at the moment a view leaves the screen it will be reused and therefore the image will be overwritten and garbage collected. If the item reenters the screen the image has to be decoded from the database again.

The decoding is reasonable fast but if the user changes the position in the list very quickly all the decoding calls will make your list very laggy.

I would implment something like an ImageCache. A class that holds a Map with WeakReferences to images. Everytime you want to display an image you take a look if the image is allready in the map and if the WeakReference still points to an object, if this is not the case you need to decode the image and then store it in the map.

Take a look at the lazy loading questions, these will show you how to put the decoding in a background task and then update the list the moment the images are loaded. It is a bit more effort but it can make the list much much more faster. If you are going to use the code example from the lazy loading questions try to use AsyncTasks instead of Threads to do the decoding in.

You're correct. Everytime I would scroll back up into view it would retrieve the image from the DB, decode it and display it. Do you have any examples where they use AsyncTasks for the decoding instead of Threads?

android - Scrolling through ListView with some images very laggy - Sta...

android performance android-listview
Rectangle 27 5

When your assets get compiled for production, they get a 'digest' added to the end of them for versioning purposes. You should use asset_path('background_stripe.png') if you're defining the class in your views or image-url('background_stripe.png') if you're defining them in your SCSS files as referenced in the docs.

Yes i used image-url aswell since its in app/assets/images but it didn't seem to work

css - Background image not showing up in heroku - Stack Overflow

css ruby-on-rails image heroku sass
Rectangle 27 4

As I wrote in the comment, you've only showed us some variables, but you need to change the views part:

var homeAccess = {
    name: 'home.access',
    url: 'access',
    views: {
       'home@': {
           templateUrl: 'app/access/partials/webapi.html'
       }
    }
};

correct... the absolute naming here should work

AngularJS ui-router view not showing up? - Stack Overflow

angularjs angular-ui-router
Rectangle 27 4

If you are using cocos2d, you may see an issue with [parentView bringSubviewToFront:view], at least it was not working for me. Instead of bringing the view I wanted to the front, I send the other views back and that did the trick.

[[[CCDirector sharedDirector] view] sendSubviewToBack:((UIButton *) button)];

ios - How to set iPhone UIView z index? - Stack Overflow

ios uiview position z-index